Use Gradle to build the default project structure for Android:
Src/main----java/----res/----assets/----aidl/----rs/----jni/----ANDROIDMA nifest.xmlsrc/androidtest/----java/
Problem one, due to sourcesets configuration: specified for property' manifest ' does not exist.
The official configuration:
Android { sourcesets { main { manifest.srcFile ' Androidmanifest.xml ' java.srcDirs = [' src '] resources.srcdirs = [' src '] aidl.srcdirs = [' src '] renderscript.srcdirs = [' src '] res.srcdirs = [ ' Res '] assets.srcdirs = [' Assets '] } }}
my configuration:
sourceSets { main { manifest.srcFile ' Src/main/androidmanifest.xml ' java.srcdirs = [' Src/main/java '] /* resources.srcdirs = [' src/ Main/res '] aidl.srcdirs = [' Src '] renderscript.srcdirs = [' src ']*/ res.srcdirs = [' src /main/res '] assets.srcdirs = [' Src/main/assets '] } }
Problem two: When your main version and the GooglePlay version of the manifest configuration are the same, it appears
Declared at Androidmanifest.xml:157:5error: (3, 5) Attribute [email protected] value= (a) from Androidmanifest.xml : 3:5error: (4, 5) Attribute [email protected] value= (2.1) from Androidmanifest.xml:4:5is also present at Androidmanifest.x Ml:4:5 value= (2.0-debug) suggestion:add ' tools:replace= ' android:versionname ' to <manifest> element at Androidmanifest.xml:1:1 to Override:app:processGooglePlayDebugManifest failederror:execution failed for Task ': app: Processgoogleplaydebugmanifest ' .> Manifest merger failed with multiple errors, see logs
Solve:
1.suggestion:add ' tools:replace= "android:versionname" to <manifest> element at Androidmanife And that's what you're saying in Androidmanifest.xml.
2. There is a way to add Useoldmanifestmerger true to the Build.gradle root tag, I tried it. So only old and honest have the first kind.
<manifest xmlns:tools= "Http://schemas.android.com/tools" xmlns:android= "http://schemas.android.com/apk/res/ Android "Tools:replace=" Android:versionname,android:versioncode "
Last on my own final version of the configuration information:
apply plugin: ' Com.android.application ' android { compilesdkversion 21 buildtoolsversion "21.1.1" defaultConfig { applicationId "Com.deetech" minSdkVersion 8 targetSdkVersion 21 versionCode 2 versionname "2.0" // AndroidManifest.xml inside Umeng The VALUE of _channel is ${UMENG_CHANNEL_VALUE} // manifestplaceholders = [umeng_channel_value: "Channel_name"] } packagingOptions{ exclude ' meta-inf/ NOTICE ' &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBsp; exclude ' meta-inf/license ' exclude ' Meta-inf/dependencies ' } /* buildTypes { release { minifyEnabled false Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.txt ' } }*/ //perform lint checks, there are any errors or warning prompts, Will terminate the build, we can turn it off. lintOptions { abortOnError false } //Signature signingConfigs { debug { &nbSp;storefile file ("C:/users/administrator/.android/debug.keystore") } relealse { storefile file ("F:/gradle.jks") //Android Studio --> Build --> Generate Signed APK --> Create New can generate storePassword "Gradle" //parameter one by one to be filled in when generating the. jks file keyAlias "Gradle" keyPassword "Gradle" &Nbsp; } } buildtypes { debug { // Show log buildConfigField "boolean", "Log_debug", "true" versionNameSuffix "-debug" minifyEnabled false zipAlignEnabled false shrinkresources false signingconfig signingconfigs.debug } release { // does not show log buildConfigField "boolean", "Log_debug", "false" //confusion minifyEnabled true //zipalign optimization zipAlignEnabled true // removing useless resource files shrinkresources true //loading default obfuscation configuration file progudard-android.txt in the SDK directory, no tube, proguard.cfg is our own <span></span> confused file proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' proguard.cfg ' //Signature signingConfig signingConfigs.relealse } } sourceSets { main { manifest.srcFile ' Src/main/androidmanifest.xml ' java.srcdirs = [' Src/main/java '] /* resources.srcdirs = [' Src/main/res '] aidl.srcdirs = [' src '] renderscript.srcdirs = [' src ']*/ res.srcdirs = [' Src/main/res '] assets.srcdirs = [' Src/main/assets '] } // move the tests to tests/ Java, tests/res, etc ... instrumenttest.setroot (' tests ') // Move the build types to build-types/<type> // For instance, build-types/debug/java, Build-types/debug/androidmanifest.xml, ... // this moves them out of them default location under src/<type>/ ... wHich would // conflict with src/ being used by the main source set. // Adding new build types or product flavors should be Accompanied // by a similar customization. debug.setroot (' Build-types/debug ') release.setroot (' build-types/release ') googleplay{ //Setting the configuration file location of the googleplay channel manifest.srcfile ' Src/main/googleplay/androidmanifest.xml ' } /* xiaomi { manifest.srcfile ' Androidmanifest.xml ' } umeng { manifest.srcFile ' Androidmanifest.xml ' }*/ } //Channel Flavors, I wrote some common productflavors {here. GooglePlay { //packagename= "Com.deetech" //here can be configured with different package names } xiaomi { //packagename= "Com.deetech" } umeng { // packagename= "Com.deetech" } } compileOptions { sourcecompatibility javaversion.version_1_7 targetcompatibility javaversion.version_1_7 } /* productflavors.all { flavor -> flavor.manifestplaceholders = [umeng_channel_value: name] }*/ //in the generated apk file, modify the name only applicationVariants.all { variant -> variant.outputs.each { output -> def outputfile = output.outputfile if (Outputfile != null && outputfile.name.endswith (' apk ')) { def filename = outputfile.name.replace (". apk", "-${defaultconfig.versionname}.apk") output.outputfile = new file (Outputfile.parent, filename) } } }} dependencies { // compile ' com.android.support:support-v4:20.0.0 ' compile filetree (dir: ' Libs ', include: [' *.jar ']) compile ' com.google.code.gson:gson:2.2.4 '}
Summary of issues encountered with Android Studio multichannel packaging