Android React Native-如何让productFlavors与不同的ApplicationID配合使用?
我有一个RN代码,我想在Android上有两种口味。这些口味在以下方面有所不同:Android React Native-如何让productFlavors与不同的ApplicationID配合使用?,android,react-native,build.gradle,android-productflavors,android-flavordimension,Android,React Native,Build.gradle,Android Productflavors,Android Flavordimension,我有一个RN代码,我想在Android上有两种口味。这些口味在以下方面有所不同: ic_发射装置和牵引装置 弦 应用程序ID 我在app/build.gradle文件中添加了product flavors,还为它们添加了一个目录res&AndroidManifest.xml 我专门用了这个零件。并成功完成了前2项。 至于applicationId,每当我更改productFlavors部分中的applicationId字段时,都会出现以下错误: `react native error: act
`react native error: activity class {mainactivity} does not exist.`
Manifest merger failed : Overlay manifest:package attribute declared at
AndroidManifest.xml:2:11-38 value=(com.examle.flavorone)
has a different value=(com.examle.flavorone) declared in main manifest at AndroidManifest.xml:2:3-24
Suggestion: remove the overlay declaration at AndroidManifest.xml and place it in the build.gradle:
flavorName {
applicationId = "com.examle.flavorone"
}
我使用以下命令运行应用程序:
react-native run-android --variant flavortoneDebug
react-native run-android --variant flavorttwoDebug
我试图更改每个flavor的清单文件中的package=”“字段,但它给了我以下错误:
`react native error: activity class {mainactivity} does not exist.`
Manifest merger failed : Overlay manifest:package attribute declared at
AndroidManifest.xml:2:11-38 value=(com.examle.flavorone)
has a different value=(com.examle.flavorone) declared in main manifest at AndroidManifest.xml:2:3-24
Suggestion: remove the overlay declaration at AndroidManifest.xml and place it in the build.gradle:
flavorName {
applicationId = "com.examle.flavorone"
}
目录按以下顺序排列:
-example
-android
---
-app
---
-src
-flavorone
-res
-AndroidManifest.xml
-flavortwo
-res
-AndroidManifest.xml
-main
-java
-res
-AndroidManifest.xml
-debug
-AndroidManifest.xml
-ios
-node_modules
-src
main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:allowBackup="false"
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>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<application
android:supportsRtl="true">
</application>
</manifest>
我搜索了其他库,也搜索了stackoverflow和其他网站,但我找不到解决方案
我非常感谢你的帮助 试试
react本地运行的android——variant-flavortoneDebug——appIdSuffix-flavorone