【发布时间】:2016-10-13 10:44:14
【问题描述】:
在为 ios 开发了 react native 应用程序之后,我还想在 android 上对其进行测试。
按照文档中的步骤并设置 Android Studio 进行测试后,我很遗憾无法运行该应用程序,因为以下错误我似乎没有找到合适的解决方案。尽管之前有人问过类似的问题。
错误:
Error:(6, -1) Android Resource Packaging: [ios_ver] /path/ios_ver/android/app/src/main/AndroidManifest.xml:6: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').
Error:(6, -1) Android Resource Packaging: [ios_ver] /path/ios_ver/android/app/src/main/AndroidManifest.xml:6: error: Error: No resource found that matches the given name (at 'icon' with value '@mipmap/ic_launcher').
Error:(6, -1) Android Resource Packaging: [ios_ver] /path/ios_ver/android/app/src/main/AndroidManifest.xml:6: error: Error: No resource found that matches the given name (at 'theme' with value '@style/AppTheme').
Error:(11, -1) Android Resource Packaging: [ios_ver] /path/ios_ver/android/app/src/main/AndroidManifest.xml:11: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').
我问了一个 Android 开发者。我的朋友,但他只说他不需要编辑清单文件,也没有类似的问题。
我的清单文件:
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:debuggable="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<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>
</manifest>
build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.ios_ver"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
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"
}
}
// 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
}
}
}
}
dependencies {
compile project(':react-native-fs')
compile project(':react-native-image-picker')
compile project(':react-native-mail')
compile project(':react-native-camera')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
// 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'
}
我很乐意听取您的任何解决方案。 感谢您的帮助。
更新
模块设置
当我单击 + 添加库时,会弹出以下窗口:
不幸的是,我没有看到任何可以从中选择 appcompat-v7 的库列表。
【问题讨论】:
标签: android android-studio react-native android-studio-2.1