【问题标题】:I'm stuck when i try to use android-image-cropper:2.8.+当我尝试使用 android-image-cropper:2.8.+ 时我被卡住了
【发布时间】:2019-03-26 03:59:30
【问题描述】:

当我在我的依赖项中添加到这一行 implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+' 它会导致错误

* 我的错误 *

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:8:5-25:19 to override.

还有

implementation 'com.android.support:appcompat-v7:28.0.0'

这条线变成红线

我认为问题是版本原因

如何避免这种冲突?

我已经尝试更改版本并在清单中添加代码

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<usespermissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

但是没用

这是我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.blogapp">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".Activities.LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Activities.RegisterActivity" />
        <activity android:name=".Activities.PostActivity" />
        <activity android:name=".Activities.HomeActivity" />
    </application>

</manifest>

这是我的依赖

apply plugin: 'com.android.application'

    android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.blogapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
    }



dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.google.firebase:firebase-core:16.0.1'

    implementation 'com.google.firebase:firebase-auth:16.0.1'

    implementation 'com.google.firebase:firebase-storage:16.0.1'

    implementation 'com.google.firebase:firebase-database:16.0.1'

    implementation "com.wdullaer:materialdatetimepicker:3.6.4"

    implementation 'com.android.support:support-v4:28.0.0'

    implementation 'com.android.support:recyclerview-v7:28.0.0'

    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'

    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:design:28.0.0'

    implementation 'de.hdodenhof:circleimageview:3.0.0'

    implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'

    implementation 'com.github.bumptech.glide:glide:4.9.0'
}

apply plugin: 'com.google.gms.google-services'

我希望使用这个 imageCropper 在我的依赖中没有问题 https://github.com/ArthurHub/Android-Image-Cropper

【问题讨论】:

    标签: android dependencies android-studio-3.0


    【解决方案1】:

    图书馆已经搬到一个新的(旧的没有维护)

    https://github.com/CanHub/Android-Image-Cropper

    阅读here

    【讨论】:

      【解决方案2】:

      我已经通过将此库作为模块导入并替换依赖项来解决此问题

      dependencies {
      api "androidx.appcompat:appcompat:$androidXLibraryVersion"
      implementation "androidx.exifinterface:exifinterface:$androidXLibraryVersion"
      }
      

      dependencies {
      api "com.android.support:appcompat-v7:28.0.0"
      implementation "com.android.support:exifinterface:28.0.0"
      }
      

      并更新库的所有文件中的导入

      【讨论】:

        【解决方案3】:

        使用版本2.7.0

        implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
        

        版本 2.8.0 使用 androidx 支持库,因此只有在您的项目中使用 androidx 支持库时才使用它

        更改日志

        2.8.0

        1. 修复 Android O 上的崩溃问题(感谢 @juliooa)
        2. 更新以支持 AndroidX 库 (感谢 @mradzinski)
        3. 选择非图像文件时处理失败(谢谢@uncledoc)
        4. 更多翻译(谢谢@jkwiecien,@david-serrano)

        编辑:

        在应用级build.gradle文件末尾添加这个

        configurations.all {
         resolutionStrategy.eachDependency {  details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion "28.0.0"
                }
            }
          }
        }
        

        感谢Eugen Pechanec

        【讨论】:

        • 我之前尝试过这样做,但是在我更改版本 2.7 之后,但是当我更改该实现时,'com.android.support:appcompat-v7:28.0.0' 显示红线并向我显示这样的消息所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 28.0.0、27.1.1。示例包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:support-v13:27.1.1 更多... (Ctrl+F1)
        【解决方案4】:

        如果你想在下面使用

        implementation com.theartofdev.edmodo:android-image-cropper:2.8.+
        

        gradle.properties文件中添加两行:

        android.useAndroidX=true
        android.enableJetifier=true
        

        【讨论】:

        • 但是在我添加这两行之后,我的一个实现发生了错误 android.support.v7.app.AppCompatActivit 这不兼容吗?
        • 是的,在您需要使用 androidx 的 AppCompatActivit 之后。这意味着您需要更改导入。
        【解决方案5】:

        不确定案例,但在遇到同样的问题后,这是因为我没有添加

        tools:replace="android:appComponentFactory"
        

        Manifest 中的这一行

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-04-22
          • 2021-07-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-02-09
          • 1970-01-01
          相关资源
          最近更新 更多