反应原生 - 无法删除android

时间:2017-08-29 15:33:56

标签: reactjs react-native react-native-android

哦,我今天在这个问题上。我想我几乎尝试过所有事情。

我无法移除的包裹:react-native-firebase

我试过了: 在代码中使用firebase完全删除所有引用,包括build.gradle文件,package.json等。 检查旧的提交并进行构建(firebase仍在那里!!!)。 尝试使用./gradlew clean清理项目。 我已删除node_modules并重新安装了多次。 清理看门狗缓存。

以前我能够构建apk(但在android上打开时会立即崩溃)。现在,我甚至不能制作apk .. 我收到错误:

/android/app/src/main/AndroidManifest.xml:9:5-81 Warning:
        Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:9:5-81 duplicated with element declared at AndroidManifest.xml:5:5-81
:app:processReleaseResources
:app:generateReleaseSources
:app:incrementalReleaseJavaCompilationSafeguard
:app:compileReleaseJavaWithJavac
:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:lintVitalRelease
:app:transformClassesWithJarMergingForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbyb.class

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

BUILD FAILED

Total time: 56.222 secs

任何帮助或建议都会非常有用。

谢谢!

编辑:删除重复权限并运行./gradlew clean后,重建和重新组装。同样的错误:

:app:incrementalReleaseJavaCompilationSafeguard
:app:compileReleaseJavaWithJavac
:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:lintVitalRelease
:app:transformClassesWithJarMergingForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbyb.class

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

BUILD FAILED

Total time: 1 mins 11.648 secs

修改

dependencies {
    compile project(':react-native-flurry-analytics')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-permissions')
    compile project(':react-native-animation')
    compile project(':react-native-mail')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.facebook.react:react-native:+'
    compile 'com.google.android.gms:play-services:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
    compile project(':react-native-share')
    compile project(':react-native-maps')
    compile project(':react-native-onesignal')
}

修改

08-30 15:30:08.871 1090-1153/com.adpages.android E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                   java.lang.RuntimeException: An error occured while executing doInBackground()
                                                                       at android.os.AsyncTask$3.done(AsyncTask.java:299)
                                                                       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
                                                                       at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:239)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
                                                                       at java.lang.Thread.run(Thread.java:856)
                                                                    Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.maps.GoogleMapOptions
                                                                       at com.airbnb.android.react.maps.AirMapManager.<init>(AirMapManager.java:52)
                                                                       at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.createAllViewManagers(XReactInstanceManagerImpl.java:699)
                                                                       at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:204)
                                                                       at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:69)
                                                                       at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:143)
                                                                       at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:140)
                                                                       at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:76)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.processPackage(XReactInstanceManagerImpl.java:954)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.createReactContext(XReactInstanceManagerImpl.java:862)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.access$600(XReactInstanceManagerImpl.java:110)
                                                                       at com.facebook.react.XReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(XReactInstanceManagerImpl.java:214)
                                                                       at com.facebook.react.XReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(XReactInstanceManagerImpl.java:193)
                                                                       at android.os.AsyncTask$2.call(AsyncTask.java:287)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:234)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                                                                       at java.lang.Thread.run(Thread.java:856) 
08-30 15:30:08.891 1090-1090/com.adpages.android D/libEGL: loaded /system/lib/egl/libEGL_genymotion.so

修改

dependencies {
    compile project(':react-native-flurry-analytics')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-permissions')
    compile project(':react-native-animation')
    compile project(':react-native-mail')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.facebook.react:react-native:+'
    compile project(':react-native-share')
    compile project(':react-native-onesignal')

    compile(project(':react-native-maps')) {
      exclude group: 'com.google.android.gms', module: 'play-services'
      exclude group: 'com.google.android.gms', module: 'play-services-maps'
      exclude group: 'com.google.android.gms', module: 'play-services-location'
      exclude group: 'com.google.android.gms', module: 'play-services-gcm'
    }
    compile 'com.google.android.gms:play-services:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    // Required for OneSignal, even if you have added FCM.
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
}

2 个答案:

答案 0 :(得分:1)

这些情况一直是Android的痛点 由于您使用的是不同版本的play-services而不是react-native-maps,因此您需要从react-native-maps中排除这些包,并像这样手动添加它们。

compile(project(':react-native-maps')) { 
    exclude group: 'com.google.android.gms', module: 'play-services-base' 
    exclude group: 'com.google.android.gms', module: 'play-services-maps' 
    exclude group: 'com.google.android.gms', module: 'play-services-location' 
exclude group: 'com.google.android.gms', module: 'play-services-gcm' 
} 
compile "com.google.android.gms:play-services-base:10.2.1" 
compile "com.google.android.gms:play-services-maps:10.2.1" 
compile 'com.google.android.gms:play-services-location:10.2.1' 
// Required for OneSignal, even if you have added FCM. 
compile 'com.google.android.gms:play-services-gcm:10.2.1'

答案 1 :(得分:0)

好像你在AndroidManifest.xml上有一个双重权限请求

你看过了吗?

Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:9:5-81 duplicated with element declared at AndroidManifest.xml:5:5-81