使用react-native-maps运行应用程序时出错,任务执行失败:':app:transformClassesWithInstantRunForDebug'

时间:2018-04-24 16:12:26

标签: react-native react-native-maps

我试图添加包' react-native-maps'到我的应用程序。

我开始关注https://www.tensorflow.org/api_docs/python/tf/nn/softmax,直到我能够在设备上运行应用程序,但地图上只显示空白的白色背景和周围的红色边框。然后我查了一下这些问题:installation guide#118但我没有运气。

我尝试重置我的本地仓库并使用#684重做它。我最终得到了以下错误,但我还没有发现任何线索:

Error:FAILURE: Build failed with an exception.
  • 出了什么问题: 任务执行失败':app:transformClassesWithInstantRunForDebug'。

      

    com.android.build.api.transform.TransformException:java.lang.RuntimeException:java.lang.RuntimeException:java.io.IOException:无法找到com / google / android / gms / maps / GoogleMap的字节代码$ OnPoiClickListener

  • 尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得全面的见解。

  • this guide

  • 获取更多帮助

在7s内建立失败

我的android / build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        google()
        maven { url 'https://maven.fabric.io/public' }
    }
dependencies {

    classpath 'io.fabric.tools:gradle:1.+'

    classpath 'com.android.tools.build:gradle:3.1.0'
    //classpath 'com.android.tools.build:gradle:2.3.3'
    //classpath 'com.android.tools.build:gradle:2.1.2'

    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}}
allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

我的android / app / build.gradle:

...
...
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"

dexOptions {
    jumboMode true
}

defaultConfig {
    applicationId "com.friendture"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 19
    versionName "1.9"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
    multiDexEnabled  true
}
signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
 }
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
 }
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }

}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}}

repositories {  
  maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile project(':react-native-fs')
    compile project(':react-native-vector-icons')
    compile project(':react-native-restart')
    compile project(':react-native-appsee')
    compile project(':react-native-contacts')
    compile project(':react-native-fbsdk')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-image-picker')
    compile project(':react-native-image-crop-picker')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile project(':react-native-fabric')
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.android.support:multidex:1.0.0'

    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true
    }

    compile(project(":react-native-google-signin")){
        exclude group: "com.google.android.gms" // very important
    }

    compile 'com.google.android.gms:play-services-auth:9.0.0' // should be at least 9.0.0

    implementation(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-base:9.0.0'
    implementation 'com.google.android.gms:play-services-maps:9.0.0'

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

更新:

我达到应用程序加载打包器%99.9然后崩溃的程度,这是我在崩溃时得到的日志:

FATAL EXCEPTION: Thread-6
Process: com.friendture, PID: 7497
                                                          java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/GoogleMap$OnPoiClickListener;
                                                              at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
                                                              at com.facebook.react.ReactInstanceManager.createAllViewManagers(ReactInstanceManager.java:660)
                                                              at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:220)
                                                              at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:75)
                                                              at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:152)
                                                              at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:149)
                                                              at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:81)
                                                              at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106)
                                                              at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1009)
                                                              at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:933)
                                                              at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109)
                                                              at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:743)
                                                              at java.lang.Thread.run(Thread.java:764)
                                                           Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.GoogleMap$OnPoiClickListener" on path: DexPathList[[zip file "/data/app/com.friendture-SzJNEe1uEBVylMi5o8IdBQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.friendture-SzJNEe1uEBVylMi5o8IdBQ==/lib/x86, /data/app/com.friendture-SzJNEe1uEBVylMi5o8IdBQ==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
                                                              at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                              at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39) 
                                                              at com.facebook.react.ReactInstanceManager.createAllViewManagers(ReactInstanceManager.java:660) 
                                                              at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:220) 
                                                              at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:75) 
                                                              at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:152) 
                                                              at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:149) 
                                                              at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:81) 
                                                              at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106) 
                                                              at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1009) 
                                                              at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:933) 
                                                              at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109) 
                                                              at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:743) 
                                                              at java.lang.Thread.run(Thread.java:764)

请随时询问任何其他相关信息。

1 个答案:

答案 0 :(得分:0)

大多数情况下,此问题与所安装的各种服务的版本有关。从今天开始,我对该服务使用了最新的版本“ com.google.android.gms:play-services-maps:16.1.0实现”(即“ 16.1.0”),错误消失并构建成功