颤振插件的问题(图像裁剪器)

时间:2021-07-09 17:20:58

标签: android flutter flutter-dependencies

我正在创建一个可以处理图像的应用程序,其中一些需要裁剪,一些不需要。我已经添加了图书馆:

image_cropper: ^1.3.1

我已经在 android manifest 中安装了依赖项:

<intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        // This is wat I had to add as said in the pub.dev from icon cropper
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
    </application>
</manifest>

但是当我运行我的应用程序时,我收到以下错误:

Launching lib\main.dart on SM N950F in debug mode...
lib\main.dart:1

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.github.yalantis:ucrop:2.2.7.
     Required by:
         project :app > project :image_cropper
      > Could not resolve com.github.yalantis:ucrop:2.2.7.
         > Could not get resource 'https://www.jitpack.io/com/github/yalantis/ucrop/2.2.7/ucrop-2.2.7.pom'.
            > Could not GET 'https://www.jitpack.io/com/github/yalantis/ucrop/2.2.7/ucrop-2.2.7.pom'.
               > Connect to www.jitpack.io:443 [www.jitpack.io/149.56.28.39] failed: Read timed out

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 36s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

这是我的 settings.gradle:

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
include ':app'
 
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
 
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
 
plugins.each { name, path ->
    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    include ":$name"
    project(":$name").projectDir = pluginDirectory
}

我也启用了 multiDex。

2 个答案:

答案 0 :(得分:0)

检查网络连接是否良好,然后重新构建项目

答案 1 :(得分:0)

我有 image_cropper 工作,一个例子供你检查和比较是否一切正常。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example">
    <uses-permission android:name="android.permission.INTERNET"/>
   <application
        android:label=""
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher">
        <activity
    android:name="com.yalantis.ucrop.UCropActivity"
    android:screenOrientation="portrait"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
           
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />

            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>
相关问题