【问题标题】:Problem with flutter plugin (Image Cropper)颤振插件的问题(图像裁剪器)
【发布时间】:2021-07-09 17:20:58
【问题描述】:

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

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。

【问题讨论】:

    标签: android flutter flutter-dependencies


    【解决方案1】:

    检查您是否有良好的互联网连接,然后再次构建项目

    【讨论】:

    【解决方案2】:

    我有 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>
    

    【讨论】:

    • 您还没有添加该行? &lt;activity android:name="com.yalantis.ucrop.UCropActivity" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Light.NoActionBar"/&gt; 在 pub.dev 中,它会在 Android 清单中添加这一行
    • 是的,我有,这是第一个&lt;activity&gt;
    • 哦,我也会尝试插入那里
    猜你喜欢
    • 1970-01-01
    • 2017-05-22
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 2015-09-30
    • 1970-01-01
    • 2021-01-30
    • 1970-01-01
    相关资源
    最近更新 更多