Modify: 添加Common项目相关公共组件
This commit is contained in:
@ -27,6 +27,8 @@ android {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resourcePrefix "base_"
|
||||||
}
|
}
|
||||||
|
|
||||||
kapt {
|
kapt {
|
||||||
|
|||||||
@ -1,5 +1 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest package="com.quyunshuo.base" />
|
||||||
package="com.quyunshuo.base">
|
|
||||||
|
|
||||||
/
|
|
||||||
</manifest>
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#6200EE</color>
|
<color name="base_colorPrimary">#6200EE</color>
|
||||||
<color name="colorPrimaryDark">#3700B3</color>
|
<color name="base_colorPrimaryDark">#3700B3</color>
|
||||||
<color name="colorAccent">#03DAC5</color>
|
<color name="base_colorAccent">#03DAC5</color>
|
||||||
</resources>
|
</resources>
|
||||||
@ -1,11 +1,11 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
<style name="base_AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/base_colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/base_colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/base_colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
1
Lib_Common/.gitignore
vendored
Normal file
1
Lib_Common/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
50
Lib_Common/build.gradle
Normal file
50
Lib_Common/build.gradle
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import com.quyunshuo.androidbaseframemvvm.build.*
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'dagger.hilt.android.plugin'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion BuildConfig.compileSdkVersion
|
||||||
|
buildToolsVersion BuildConfig.buildToolsVersion
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion BuildConfig.minSdkVersion
|
||||||
|
targetSdkVersion BuildConfig.targetSdkVersion
|
||||||
|
versionCode BuildConfig.versionCode
|
||||||
|
versionName BuildConfig.versionName
|
||||||
|
testInstrumentationRunner AndroidX.AndroidJUnitRunner
|
||||||
|
consumerProguardFiles "consumer-rules.pro"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
resourcePrefix "common_"
|
||||||
|
}
|
||||||
|
|
||||||
|
kapt {
|
||||||
|
arguments {
|
||||||
|
arg("AROUTER_MODULE_NAME", project.getName())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
|
|
||||||
|
api project(path: ':Lib_Base')
|
||||||
|
|
||||||
|
implementation JetPack.HiltDaggerAndroid
|
||||||
|
kapt JetPack.HiltDaggerCompiler
|
||||||
|
kapt JetPack.Hilt
|
||||||
|
kapt GitHub.GlideCompiler
|
||||||
|
kapt GitHub.ARouteCompiler
|
||||||
|
}
|
||||||
0
Lib_Common/consumer-rules.pro
Normal file
0
Lib_Common/consumer-rules.pro
Normal file
21
Lib_Common/proguard-rules.pro
vendored
Normal file
21
Lib_Common/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.quyunshuo.common
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
assertEquals("com.quyunshuo.common.test", appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Lib_Common/src/main/AndroidManifest.xml
Normal file
1
Lib_Common/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
|||||||
|
<manifest package="com.quyunshuo.common" />
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.quyunshuo.common
|
||||||
|
|
||||||
|
import com.quyunshuo.base.BaseApplication
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: QuYunShuo
|
||||||
|
* @Time: 2020/8/27
|
||||||
|
* @Class: CommonApplication
|
||||||
|
* @Remark: 项目相关的Application
|
||||||
|
*/
|
||||||
|
open class CommonApplication : BaseApplication() {
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.quyunshuo.common
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
fun addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,10 +3,15 @@ package com.quyunshuo.main
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: QuYunShuo
|
||||||
|
* @Time: 2020/8/27
|
||||||
|
* @Class: MainActivity
|
||||||
|
* @Remark: 主界面Activity
|
||||||
|
*/
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.main_activity_main)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,10 +3,10 @@
|
|||||||
package="com.quyunshuo.main">
|
package="com.quyunshuo.main">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="com.quyunshuo.base.BaseApplication"
|
android:name="com.quyunshuo.common.CommonApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:label="@string/main_app_name"
|
android:label="@string/main_app_name"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/base_AppTheme">
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
@ -6,4 +6,12 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Main"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -1,5 +1,2 @@
|
|||||||
# Android项目框架(组件化 + Kotlin + MVVM + Jetpack )
|
# Android项目框架(组件化 + Kotlin + MVVM + Jetpack )
|
||||||
note: 1. 组件间资源命名冲突问题
|
note: 1. 测试打包脚本
|
||||||
2. 组件间不同模式下的清单文件及其他
|
|
||||||
3. 测试打包脚本
|
|
||||||
4. Application
|
|
||||||
@ -72,6 +72,6 @@ dependencies {
|
|||||||
if (!BuildConfig.isAppMode) {
|
if (!BuildConfig.isAppMode) {
|
||||||
implementation project(path: ':Lib_Main')
|
implementation project(path: ':Lib_Main')
|
||||||
} else {
|
} else {
|
||||||
implementation project(path: ':Lib_Base')
|
implementation project(path: ':Lib_Common')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,6 +9,6 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme" />
|
android:theme="@style/base_AppTheme" />
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@ -1,7 +1,7 @@
|
|||||||
package com.quyunshuo.androidbaseframemvvm
|
package com.quyunshuo.androidbaseframemvvm
|
||||||
|
|
||||||
import androidx.multidex.MultiDex
|
import androidx.multidex.MultiDex
|
||||||
import com.quyunshuo.base.BaseApplication
|
import com.quyunshuo.common.CommonApplication
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: QuYunShuo
|
* @Author: QuYunShuo
|
||||||
@ -9,10 +9,10 @@ import com.quyunshuo.base.BaseApplication
|
|||||||
* @Class: AppApplication
|
* @Class: AppApplication
|
||||||
* @Remark: 壳App的Application 负责需要写在App包下的初始化逻辑
|
* @Remark: 壳App的Application 负责需要写在App包下的初始化逻辑
|
||||||
*/
|
*/
|
||||||
class AppApplication : BaseApplication() {
|
class AppApplication : CommonApplication() {
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
|
||||||
MultiDex.install(this)
|
MultiDex.install(this)
|
||||||
|
super.onCreate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ kapt {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
api project(path: ':Lib_Base')
|
api project(path: ':Lib_Common')
|
||||||
|
|
||||||
testImplementation Android.Junit
|
testImplementation Android.Junit
|
||||||
androidTestImplementation AndroidX.TestExtJunit
|
androidTestImplementation AndroidX.TestExtJunit
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
include ':Lib_Common'
|
||||||
include ':Lib_Main'
|
include ':Lib_Main'
|
||||||
include ':Lib_Base'
|
include ':Lib_Base'
|
||||||
include ':app'
|
include ':app'
|
||||||
|
|||||||
Reference in New Issue
Block a user