在构建本机映射时编译错误

时间:2018-11-04 02:57:49

标签: react-native

我是react-native的新手,在尝试使用react-native-maps进行构建时一直遇到错误。 我所做的步骤:

react-native init --version="0.57.4" <my_app_name>
cd <my_app_name>
react-native install react-native-geocoder
react-native install react-native-maps
react-native run-android

错误消息:

> Task :react-native-maps:compileDebugJavaWithJavac 
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.v4.app.ActivityCompat

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

按照@ samitha-nanayakkara的指示,我到达了issue,我确实尝试每次删除构建目录并像这样编辑android/app/build.gradle

defaultConfig {
...
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

那给我错误信息:

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.v4.app.ActivityCompat


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

另外,尝试Java 8也能得到相同的结果:

defaultConfig {
...
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

multiDexEnabled true添加到a​​ndroid / app / build.gradle会给我另一个错误消息:

FAILURE: Build failed with an exception. 
* What went wrong: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. > com.android.build.api.transform.TransformException: Error while generating the main dex list.

我该如何解决?

0 个答案:

没有答案