入口函数
package com.example.pakeing; import android.app.Application; import com.umeng.commonsdk.UMConfigure; /** * Created by Administrator on 2018/5/13 0013. */ public class RuKou extends Application { @Override public void onCreate() { super.onCreate(); UMConfigure.init(this,UMConfigure.DEVICE_TYPE_PHONE,null); } }
Manifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.pakeing"> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:name=".RuKou" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <meta-data android:value="5af69e97b27b0a071c000405" android:name="UMENG_APPKEY"/> <meta-data android:value="${UMENG_CHANNEL_VALUE}" android:name="UMENG_CHANNEL"/> </application> </manifest>
project gradle /
allprojects { repositories { jcenter() mavenCentral() } }
modle gradle
apply plugin: 'com.android.application' android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { applicationId "com.example.pakeing" minSdkVersion 15 targetSdkVersion 27 versionCode 1 versionName "1.0" //这里面 manifestPlaceholders=[UMENG_CHANNEL_VALUE:"umeng"] testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' /* signingConfig signingConfig.release*/ //用来更改包名后缀 使他们能安装在一个手机上 applicationVariants.all{ variant-> variant.outputs.each{ output-> def outputFile=output.outputFile if(outputFile!=null&&outputFile.name.endsWith(".apk")){ def fileName="${variant.productFlavors[0].name}"+".apk" output.outputFile=new File(outputFile.parent,fileName); } } } /* studio 3.0 用这个 android.applicationVariants.all{ variant-> variant.outputs.all{ outputFileName="${variant.productFlavors[0].name}.apk" } }*/ } } //别的博客中来的脚本 productFlavors { default_channel{} wandoujia{} _360{} yingyongbao{} xiaomi{} baidu{} huawei{} jifeng{} } productFlavors.all { flavor -> flavor.manifestPlaceholders = [ UMENG_CHANNEL_VALUE:name ] } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile 'com.umeng.sdk:common:latest.integration' compile 'com.umeng.sdk:analytics:latest.integration' }
脚本来源博客
https://blog.csdn.net/gulihui890411/article/details/48574051