我正在使用 react native(detached) 构建应用程序,在使用 npm install 安装 onesignal 库后,我无法再在 Android Studio 上构建我的应用程序。
以下是错误:
清单合并失败:属性 meta-data#android.support.VERSION@value value=(26.0.2) from [com.android.support:appcompat-v7:26.0.2] AndroidManifest.xml:28:13-35 也是出现在 [com.android.support:exifinterface:26.0.1] AndroidManifest.xml:25:13-35 value=(26.0.1)。建议:将 'tools:replace="android:value"' 添加到 AndroidManifest.xml:26:9-28:38 的元素以覆盖。
我在 react-native-onesignal build.gradle 中所做的更改我将 buildtoolsversion 更改为 26.02,因为它是 23.0.1 smth ... 以下是当前 react-native-onesignal 的外观:
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
android {
compileSdkVersion safeExtGet('compileSdkVersion', 23)
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.2')
defaultConfig {
// Do NOT change these values here, set them in your android/app/build.gradle instead
manifestPlaceholders = [onesignal_app_id: '', onesignal_google_project_number: 'REMOTE']
minSdkVersion safeExtGet('minSdkVersion', 16)
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
compile('com.onesignal:OneSignal:3.8.3') {
// Exclude com.android.support(Android Support library) as the version range starts at 26.0.0
// This is due to compileSdkVersion defaulting to 23 which cant' be lower than the support library version
// And the fact that the default root project is missing the Google Maven repo required to pull down 26.0.0+
exclude group: 'com.android.support'
// Keeping com.google.android.gms(Google Play services library) as this version range starts at 10.2.1
}
testCompile 'junit:junit:4.12'
}
我的应用程序 build.gradle 看起来像:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
flavorDimensions "default"
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'com.ferrometal'
targetSdkVersion 25
versionCode 1
versionName '1.0.0'
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Deprecated. Used by net.openid:appauth
manifestPlaceholders = [
'appAuthRedirectScheme': 'host.exp.exponent'
]
}
dexOptions {
javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
}
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
devRemoteKernel {
minSdkVersion 21
}
dev19 {
// For debugging / development on older SDK versions. Increases build
// time so use 'dev' if not running on older SDKs.
minSdkVersion 19
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 19
}
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
signingConfigs {
debug {
storeFile file('../debug.keystore')
}
}
lintOptions {
abortOnError false
}
packagingOptions {
pickFirst "**"
}
}
// Don't use modern jsc-android since it still has some critical bugs that
// crash applications when the string for the JS bundle is loaded and when
// locale-specific date functions are called.
// configurations.all {
// resolutionStrategy {
// force 'org.webkit:android-jsc:r216113'
// }
// }
task exponentPrebuildStep(type: Exec) {
workingDir '../'
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', '.\\detach-scripts\\prepare-detached-build.bat'
} else {
commandLine './detach-scripts/prepare-detached-build.sh'
}
}
preBuild.dependsOn exponentPrebuildStep
dependencies {
compile project(':react-native-onesignal')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
// Our dependencies
compile 'com.android.support:appcompat-v7:26.0.2'
// Our dependencies from ExpoView
// DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile('com.facebook.android:audience-network-sdk:4.22.1') {
exclude module: 'play-services-ads'
}
provided 'org.glassfish:javax.annotation:3.1.1'
annotationProcessor 'com.jakewharton:butterknife:7.0.1'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.amplitude:android-sdk:2.9.2' // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-gcm:9.8.0'
compile 'com.google.android.gms:play-services-analytics:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.android.gms:play-services-auth:9.8.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.android.gms:play-services-ads:9.8.0'
compile "com.raizlabs.android:DBFlow-Core:2.2.1"
compile "com.raizlabs.android:DBFlow:2.2.1"
compile "com.madgag.spongycastle:core:1.53.0.0"
compile "com.madgag.spongycastle:prov:1.53.0.0"
debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
compile 'com.facebook.device.yearclass:yearclass:1.0.1'
compile 'commons-io:commons-io:1.3.2'
compile 'me.leolin:ShortcutBadger:1.1.4@aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
compile 'com.yqritc:android-scalablevideoview:1.0.1'
compile 'commons-codec:commons-codec:1.10'
compile 'com.segment.analytics.android:analytics:4.3.0'
compile 'com.google.zxing:core:3.2.1'
compile 'net.openid:appauth:0.4.1'
compile 'com.airbnb.android:lottie:2.2.0'
compile 'io.branch.sdk.android:library:2.6.1'
compile('io.nlopez.smartlocation:library:3.2.11') {
transitive = false
}
compile 'com.android.support:exifinterface:26.0.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
compile 'com.squareup.okio:okio:1.9.0'
// Testing
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
// We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support:support-annotations:26.0.1'
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
androidTestCompile 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'
compile('host.exp.exponent:expoview:26.0.0@aar') {
transitive = true
}
}
// This has to be down here for some reason
apply plugin: 'com.google.gms.google-services'
AAndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="host.exp.exponent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<permission
android:name="com.ferrometal.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<!-- These are required permissions to make the app run -->
<uses-permission android:name="com.ferrometal.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- ADD PERMISSIONS HERE -->
<!-- BEGIN OPTIONAL PERMISSIONS -->
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<!-- These require runtime permissions on M -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- END OPTIONAL PERMISSIONS -->
<!-- ADD TEST PERMISSIONS HERE -->
<uses-feature android:glEsVersion="0x00020000" android:required="false" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true">
<activity
android:name=".LauncherActivity"
android:exported="true"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<data android:scheme="expac59f8b2959f4de3afc2b84696f00c3d"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity
android:name=".experience.ExperienceActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:theme="@style/Theme.Exponent.Light"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:theme="@style/Theme.Exponent.Splash"
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=".experience.ShellAppActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:theme="@style/Theme.Exponent.Splash"
android:windowSoftInputMode="adjustResize">
<!-- ADD SHELL INTENT FILTERS HERE -->
</activity>
<activity
android:name=".experience.HomeActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/Theme.Exponent.Light">
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<!-- ADD DEV SETTINGS HERE -->
<activity android:name="abi26_0_0.com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="abi25_0_0.com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="abi24_0_0.com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="abi23_0_0.com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="abi22_0_0.com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="abi21_0_0.com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="abi20_0_0.com.facebook.react.devsupport.DevSettingsActivity"/>
<activity
android:name=".ExponentDevActivity"
android:exported="true"
android:label="@string/dev_activity_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.Exponent.Dark"
android:windowSoftInputMode="adjustPan">
</activity>
<activity
android:name=".oauth.OAuthWebViewActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Exponent.Light">
</activity>
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="com.ferrometal" android:path="oauthredirect"/>
</intent-filter>
</activity>
<activity
android:name=".oauth.OAuthResultActivity">
</activity>
<activity
android:name=".chrometabs.ChromeTabsManagerActivity">
</activity>
<activity
android:name=".experience.ErrorActivity"
android:theme="@style/Theme.Exponent.Dark"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".experience.InfoActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Exponent.Light">
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
tools:replace="android:theme" />
<activity
android:name="com.facebook.ads.InterstitialAdActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<service
android:name=".ExponentIntentService"
android:exported="false" />
<!-- Analytics -->
<receiver
android:name="host.exp.exponent.referrer.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<!--
This crashes: https://code.google.com/p/analytics-issues/issues/detail?id=667
TODO: turn it back on when it's fixed
<service
android:name="com.google.android.gms.analytics.CampaignTrackingService"
android:enabled="true"
android:exported="false" />-->
<receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
<!-- GCM -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.ferrometal"/>
</intent-filter>
</receiver>
<service
android:name=".gcm.ExponentGcmListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<service
android:name=".gcm.ExponentInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name=".gcm.RegistrationIntentService"
android:exported="false">
</service>
<!-- ImagePicker native module -->
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat">
</activity>
<!-- ADD FABRIC CONFIG HERE -->
<!-- BEGIN FABRIC CONFIG -->
<meta-data
android:name="io.fabric.ApiKey"
android:value="a25fafe9f9edee11a9882b32e0cd7a26df6e2c42"/>
<!-- END FABRIC CONFIG -->
<!-- ADD GOOGLE MAPS CONFIG HERE -->
<!-- BEGIN GOOGLE MAPS CONFIG -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCPyKmt6in3JwAsogYikNNjor8qgU9stRQ"/>
<!-- END GOOGLE MAPS CONFIG -->
<!-- ADD BRANCH CONFIG HERE -->
<!-- The Facebook SDK runs FacebookInitProvider on startup and crashes if there isn't an ID here -->
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb0"/>
</application>
</manifest>