Reputation: 3641
after developing the react native app for ios I wanted to also test it on android.
After following the steps from the docs and setting up Android Studio to test I sadly can't run the app because of the following errors to which I don't seem to find the proper solution. Even though similar questions have been asked before.
The errors:
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').
I asked an Android Dev. Friend of mine, but he only said that he never needed to edit the manifest file nor had a similar problem.
My Manifest File:
<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'
}
I'll gladly hear any kind of solution from you. Thanks for your help.
UPDATE
Module Settings
When I click the + to add a Library then the following window pops up:
Unfortunately I don't see any list of libraries from which i could choose appcompat-v7.
Upvotes: 4
Views: 3199
Reputation: 515
Fix for React Native App:
You must run it through the command react-native run-android as stated in the official docs.
Fix if you are not using React Native:
Your Android Manifest
file is missing some things that are required to run your app. Most of these are under the <application
</application>
tags. Here is an example below which you can use to fix yours:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.prad.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
After comparing you manifest with the one above, try the following below:
Check string resources:
Path: res/values/strings.xml
<string name="app_name">"MyFirstApp"</string>
Check style resources:
Path: res/values/styles
Change The.AppCompat.Light.DarkActionBar to Theme.Light
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Check build.gradle
Change buildToolsVersion "23.0.1"
to buildToolsVersion "21.1.1"
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
Something else to debug this issue:
Right click on your app
Open Module Settings
Select Dependencies tab
Click on green + symbol which is on the right side
Select Library Dependency
Choose appcompat-v7 from list
Upvotes: 4
Reputation: 3641
I have managed to simulate this react native android app.
While you can run your react native IOS App directly from Xcode, it seems that it doesn't work if you run your react native Android App directly from the Android Studio.
You must run it through the command react-native run-android as stated in the docs
Upvotes: 0