Search code examples
androidandroid-studioreact-nativeandroid-studio-2.1

"No resource found that matches the given name..:" - Android Studio 2.1.2 (React Native App)


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

enter image description here

When I click the + to add a Library then the following window pops up:

enter image description here

Unfortunately I don't see any list of libraries from which i could choose appcompat-v7.


Solution

  • 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