Commit dc4c934e authored by fengruiyu's avatar fengruiyu

项目正常跑起来

parent 7c16a2b2
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" /> <bytecodeTargetLevel target="11" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations> </configurations>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
<option name="id" value="Android" /> <option name="id" value="Android" />
</component> </component>
<component name="SuppressKotlinCodeStyleNotification">
<option name="disableForAll" value="true" />
</component>
</project> </project>
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<component name="RunConfigurationProducerService"> <component name="RunConfigurationProducerService">
<option name="ignoredProducers"> <option name="ignoredProducers">
<set> <set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
......
...@@ -10,6 +10,10 @@ android { ...@@ -10,6 +10,10 @@ android {
targetSdkVersion rootProject.ext.android.targetSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName versionName rootProject.ext.android.versionName
//flavorDimensions "default"
buildConfigField ("boolean","IS_DEV","false")
} }
dataBinding { dataBinding {
...@@ -19,31 +23,50 @@ android { ...@@ -19,31 +23,50 @@ android {
sourceCompatibility rootProject.ext.java_version["compileJavaVersion"] sourceCompatibility rootProject.ext.java_version["compileJavaVersion"]
targetCompatibility rootProject.ext.java_version["targetJavaVersion"] targetCompatibility rootProject.ext.java_version["targetJavaVersion"]
} }
productFlavors { // buildTypes {
// 开发版本 // debug {
auto { // minifyEnabled false
buildConfigField ('boolean','IS_DEV',"true") // //signingConfig signingConfigs.release
manifestPlaceholders = [ // zipAlignEnabled true
app_logo_name: "Auto" // versionNameSuffix "-dev"
] // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} // }
// 线上产品版本 // release {
product { // minifyEnabled false
buildConfigField ('boolean','IS_DEV',"false") // zipAlignEnabled true
manifestPlaceholders = [ // shrinkResources false
app_logo_name: "线上" // //signingConfig signingConfigs.release
] // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} // }
} // }
// productFlavors {
// // 开发版本
// auto {
// buildConfigField ('boolean','IS_DEV',"true")
// manifestPlaceholders = [
// app_logo_name: "Auto"
// ]
// }
// // 线上产品版本
// product {
// buildConfigField ('boolean','IS_DEV',"false")
// manifestPlaceholders = [
// app_logo_name: "线上"
// ]
// }
// }
} }
dependencies { dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation rootProject.ext.support["junit"]
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' // implementation 'androidx.appcompat:appcompat:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' // implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test.ext:junit:1.1.1'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api project(':library_base') api project(':library_base')
......
# 环境名
name=product
api.base.url=https://
isProduct=true
\ No newline at end of file
# 环境名 默认
name=test
api.base.url=http://apitest.
isProduct=false
\ No newline at end of file
{
"supplier":{
"vivo":{
"appid":"103881568"
},
"xiaomi":{
"appid": "2882303761518348857"
},
"huawei":{
"appid": "101833995"
},
"oppo":{
"appid": "30251013"
}
}
}
# 环境名
name=product
api.base.url=https://api.
isProduct=true
\ No newline at end of file
{
"supplier":{
"vivo":{
"appid":"103881568"
},
"xiaomi":{
"appid": "2882303761518348857"
},
"huawei":{
"appid": "101833995"
},
"oppo":{
"appid": "30251013"
}
}
}
...@@ -16,7 +16,10 @@ android { ...@@ -16,7 +16,10 @@ android {
flavorDimensions '23' flavorDimensions '23'
multiDexEnabled true multiDexEnabled true
buildConfigField ("boolean","IS_DEV","false") buildConfigField ("boolean","IS_DEV","false")
buildConfigField ("String","AppKeyPre","abcd") //从com.android.tools.build:gradle:4.1.0开始,build.gradle文件正式移除了versionName和versionCode,参照Android开发者官网。
buildConfigField ("String","VERSION_NAME", "\"" + rootProject.ext.android.versionName + "\"")
buildConfigField ("String","VERSION_CODE", "\"" + rootProject.ext.android.versionCode + "\"")
buildConfigField ("String","AppKeyPre","\"" + "abcd" + "\"")
} }
...@@ -52,17 +55,17 @@ android { ...@@ -52,17 +55,17 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
productFlavors { // productFlavors {
//包含所有环境 // //包含所有环境
auto { // auto {
buildConfigField ("boolean","IS_DEV","true") // buildConfigField ("boolean","IS_DEV","true")
} // }
// 线上产品版本 // // 线上产品版本
product { // product {
buildConfigField ("boolean","IS_DEV","false") // buildConfigField ("boolean","IS_DEV","false")
} // }
} // }
//
compileOptions { compileOptions {
sourceCompatibility rootProject.ext.java_version["compileJavaVersion"] sourceCompatibility rootProject.ext.java_version["compileJavaVersion"]
......
...@@ -23,13 +23,13 @@ android { ...@@ -23,13 +23,13 @@ android {
buildConfigField ("int","BUILD_VERSION","${buildVersion}") buildConfigField ("int","BUILD_VERSION","${buildVersion}")
} }
// noArg { noArg {
// annotation("com.jeme.base.annotation.Poko") annotation("com.jeme.base.annotation.Poko")
// } }
//
// allOpen { allOpen {
// annotation("com.jeme.base.annotation.Poko") annotation("com.jeme.base.annotation.Poko")
// } }
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs') implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
......
...@@ -4,9 +4,7 @@ import android.app.Application; ...@@ -4,9 +4,7 @@ import android.app.Application;
import android.view.Gravity; import android.view.Gravity;
import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.android.arouter.launcher.ARouter;
import com.fry.base.BuildConfig;
import com.fry.base.global.Constants; import com.fry.base.global.Constants;
import com.fry.base.utils.PropertyUtils;
import com.tencent.bugly.crashreport.CrashReport; import com.tencent.bugly.crashreport.CrashReport;
import me.goldze.mvvmhabit.utils.KLog; import me.goldze.mvvmhabit.utils.KLog;
...@@ -21,15 +19,14 @@ import me.goldze.mvvmhabit.utils.ToastUtils; ...@@ -21,15 +19,14 @@ import me.goldze.mvvmhabit.utils.ToastUtils;
public class BaseModuleInit implements IModuleInit<Void> { public class BaseModuleInit implements IModuleInit<Void> {
@Override @Override
public boolean onInitAhead(Application application,boolean isMainProcess) { public boolean onInitAhead(Application application,boolean isMainProcess) {
// 环境配置读取初始化优先级最高,要先初始化
PropertyUtils.init(application);
//开启打印日志 //开启打印日志
KLog.init(BuildConfig.DEBUG); // KLog.init(BuildConfig.DEBUG);
//初始化阿里路由框架 // //初始化阿里路由框架
if (BuildConfig.DEBUG) { // if (BuildConfig.DEBUG) {
ARouter.openLog(); // 打印日志 // ARouter.openLog(); // 打印日志
ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险) // ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
} // }
// 尽可能早,推荐在Application中初始化 // 尽可能早,推荐在Application中初始化
ARouter.init(application); ARouter.init(application);
ToastUtils.setGravity(Gravity.CENTER,0,0); ToastUtils.setGravity(Gravity.CENTER,0,0);
...@@ -42,9 +39,9 @@ public class BaseModuleInit implements IModuleInit<Void> { ...@@ -42,9 +39,9 @@ public class BaseModuleInit implements IModuleInit<Void> {
// 这里实现SDK初始化,appId替换成你的在Bugly平台申请的appId // 这里实现SDK初始化,appId替换成你的在Bugly平台申请的appId
// 调试时,将第三个参数改为true // 调试时,将第三个参数改为true
// Bugly.init(application, Constants.BUGLY_APP_ID, BuildConfig.IS_DEV); // Bugly.init(application, Constants.BUGLY_APP_ID, BuildConfig.IS_DEV);
if(!BuildConfig.IS_DEV && ! SPUtils2.getInstance().decodeBoolean("isFirstOpen", true)){ // if(!BuildConfig.IS_DEV && ! SPUtils2.getInstance().decodeBoolean("isFirstOpen", true)){
CrashReport.initCrashReport(application, Constants.BUGLY_APP_ID, false); // CrashReport.initCrashReport(application, Constants.BUGLY_APP_ID, false);
} // }
return null; return null;
} }
......
package com.fry.base.global; package com.fry.base.global;
import com.fry.base.utils.PropertyUtils;
/** /**
* Created by jeme on 2019/9/17 * Created by jeme on 2019/9/17
*/ */
...@@ -56,6 +54,8 @@ public class Constants { ...@@ -56,6 +54,8 @@ public class Constants {
} }
public static String getBaseUrl() { public static String getBaseUrl() {
return PropertyUtils.getApiBaseUrl(); //fry
// return PropertyUtils.getApiBaseUrl();
return "";
} }
} }
\ No newline at end of file
...@@ -52,7 +52,9 @@ public class InitConstants { ...@@ -52,7 +52,9 @@ public class InitConstants {
public static int getVersionCode() { public static int getVersionCode() {
if (VERSION_CODE == null) { if (VERSION_CODE == null) {
return BuildConfig.VERSION_CODE; //fry
//return BuildConfig.VERSION_CODE;
return 0;
} }
return VERSION_CODE; return VERSION_CODE;
} }
...@@ -66,6 +68,7 @@ public class InitConstants { ...@@ -66,6 +68,7 @@ public class InitConstants {
public static String getVersionName() { public static String getVersionName() {
if (VERSION_NAME == null) { if (VERSION_NAME == null) {
return BuildConfig.VERSION_NAME; return BuildConfig.VERSION_NAME;
return "";
} }
return VERSION_NAME; return VERSION_NAME;
} }
......
...@@ -2,6 +2,7 @@ package com.fry.base.netwrok ...@@ -2,6 +2,7 @@ package com.fry.base.netwrok
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
import com.fry.base.BuildConfig
import com.fry.base.bean.AppRequest import com.fry.base.bean.AppRequest
import com.fry.base.utils.encry.AESUtils import com.fry.base.utils.encry.AESUtils
import com.fry.base.utils.encry.Base64 import com.fry.base.utils.encry.Base64
......
package com.fry.base.utils;
import android.content.Context;
import androidx.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
/**
* 2019-10-18 created
*
* @author KOM
*/
public class BuildConfigUtils {
/**
* 在build.gradle中配置字段的KEY
*/
@StringDef({ConfigField.DEBUG, ConfigField.APPLICATION_ID,
ConfigField.BUILD_TYPE, ConfigField.FLAVOR,
ConfigField.VERSION_CODE, ConfigField.VERSION_NAME})
@Retention(RetentionPolicy.SOURCE)
public @interface ConfigField {
String DEBUG = "DEBUG";
String APPLICATION_ID = "APPLICATION_ID";
String BUILD_TYPE = "BUILD_TYPE";
String FLAVOR = "FLAVOR";
String VERSION_CODE = "VERSION_CODE";
String VERSION_NAME = "VERSION_NAME";
}
/**
* 获取APP模块下配置的 buildConfigField 的值
*/
public static <T> T getBuildConfigValue(Context context, @ConfigField String fieldName) {
try {
Class<?> clazz = Class.forName(context.getPackageName() + ".BuildConfig");
Field field = clazz.getField(fieldName);
return (T) field.get(null);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
}
package com.fry.base.utils;
import androidx.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* 2019-10-18 created
*
* @author KOM
*/
@StringDef({PropertyKey.BASE_URL,PropertyKey.IS_PRODUCT})
@Retention(RetentionPolicy.SOURCE)
public @interface PropertyKey {
String NAME = "name";
String BASE_URL = "api.base.url";
String IS_PRODUCT = "isProduct";
}
package com.fry.base.utils;
import android.content.Context;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import me.goldze.mvvmhabit.utils.Utils;
/**
* 2019-10-18 created
*
* @author KOM
*/
public class PropertyUtils {
private static Properties mProps = new Properties();
private static boolean mHasLoadProps = false;
private static final Object mLock = new Object();
private static final String TAG = "PropertyUtils";
public PropertyUtils() {
}
/**
* 初始化 级别应该最高
*/
public static void init(Context context) {
if (!mHasLoadProps) {
synchronized (mLock) {
if (!mHasLoadProps) {
try {
ConfigManager.EnvironmentType environmentType = ConfigManager.getDefault().getAppEnv();
InputStream is = context.getAssets().open(environmentType.configType+".properties");
mProps.load(is);
mHasLoadProps = true;
Log.d("PropertyUtils", "load config.properties successfully!");
} catch (IOException var4) {
Log.e("PropertyUtils", "load config.properties error!", var4);
}
}
}
}
}
public static String getApiBaseUrl() {
if (mProps == null) {
throw new IllegalArgumentException("must call #UtilsManager.init(context) in application");
} else {
return mProps.getProperty(PropertyKey.BASE_URL, "");
}
}
public static boolean isProduct() {
return mProps.getProperty(PropertyKey.IS_PRODUCT, "false").equals("true");
}
public static String getEnvironmentName() {
return mProps.getProperty(PropertyKey.NAME, "");
}
public static ConfigManager.EnvironmentType environmentMap() {
String envName = getEnvironmentName();
switch (envName){
case "product":
return ConfigManager.EnvironmentType.PRODUCT;
default:
return ConfigManager.EnvironmentType.TEST;
}
}
public static boolean isDebug() {
Boolean isDebug = BuildConfigUtils.getBuildConfigValue(
Utils.getContext(), BuildConfigUtils.ConfigField.DEBUG);
return isDebug == null ? true : isDebug;
}
public static String getValueByKey(String key) {
return mProps.getProperty(key, "");
}
}
...@@ -3,6 +3,8 @@ package com.fry.base.utils.encry; ...@@ -3,6 +3,8 @@ package com.fry.base.utils.encry;
import android.util.Log; import android.util.Log;
import com.fry.base.BuildConfig;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
......
#Wed Jun 30 17:38:32 CST 2021 #Wed Jun 30 19:52:15 CST 2021
VERSION_BUILD=2228 VERSION_BUILD=2320
...@@ -19,7 +19,9 @@ android { ...@@ -19,7 +19,9 @@ android {
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs') //implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
provided files('libs\\xpopup-release.aar')
//support //support
api rootProject.ext.support["support-v4"] api rootProject.ext.support["support-v4"]
api rootProject.ext.support["appcompat-v7"] api rootProject.ext.support["appcompat-v7"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment