【发布时间】:2018-07-01 03:16:22
【问题描述】:
我不确定为什么会发生这种情况,但我进行了一些挖掘并试图找到其他解决方案。没有人提出特别重复的问题:
android {
compileSdkVersion 26
buildToolsVersion "23.0.3"
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':react-native-customized-image-picker')
compile project(':react-native-vector-icons')
compile project(':react-native-restart')
compile project(':react-native-image-picker')
compile project(':react-native-fast-image')
compile project(':lottie-react-native')
compile project(':react-native-fetch-blob')
compile "com.android.support:multidex:1.0.1"
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.fresco:fresco:1.0.1"
compile "com.facebook.fresco:animated-gif:1.0.1"
compile("com.facebook.react:react-native:0.54.0") { force = true } // From node_modules
}
我删除了一些我发现的重复的compiles,但仍然没有帮助。我在跟踪中注意到了这个警告:
C:\ReactProjects\myapp\android\app\src\main\AndroidManifest.xml:11:5-29:19 Warning:
application@android:theme was tagged at AndroidManifest.xml:11 to replace other declarations but no other declaration present
C:\ReactProjects\myapp\android\app\src\main\AndroidManifest.xml:16:9-19:35 Warning:
meta-data#com.bumptech.glide.integration.okhttp.OkHttpGlideModule was tagged at AndroidManifest.xml:16 to remove other declarations but no other declaration present
我不知道这是否会导致整个事情失败。最后是我的清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
tools:replace="android:theme"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
在尝试成功构建时遇到的每一个问题,我都查看了 SO 或其他来源,但这个问题占了上风。我之前从未插入过compile "com.android.support:multidex:1.0.1",并且在此问题发生之前它就起作用了。还是没有成功。
我记得做的最后一件事是在主目录中保存一个名为“safecode.js”的文件,基本上它只有我想要保存的代码。
【问题讨论】:
-
访问以下链接,希望您能得到答案:stackoverflow.com/questions/25981156/…
-
或者尝试在清单文件的应用标签中添加这一行:tools:replace="icon, label" ---------e-g
-
@Opriday 我仍然收到错误消息。我觉得因为清单只是有警告它不会影响构建过程,但我认为它与
build.gradle
标签: android react-native gradle compiler-errors