@@ -60,10 +60,10 @@ trait AndroidAppModule extends AndroidModule { outer =>
60
60
protected val debugKeyPass = " mill-android"
61
61
62
62
/**
63
- * The namespace of the android application which is used
64
- * to specify the fully qualified classpath of the activity .
63
+ * Every Android module has a namespace,
64
+ * which is used as the Kotlin or Java package name for its generated R and BuildConfig classes .
65
65
*
66
- * For instance, it is used as the package name in Android Manifest
66
+ * See more in [[ https://developer.android.com/build/configure-app-module#set-namespace ]]
67
67
*/
68
68
def androidApplicationNamespace : String
69
69
@@ -74,10 +74,8 @@ trait AndroidAppModule extends AndroidModule { outer =>
74
74
override final def androidNamespace : String = androidApplicationNamespace
75
75
76
76
/**
77
- * Android Application Id which is typically package.main .
78
- * Can be used for build variants.
79
- *
80
- * Build variant feature is not yet implemented!
77
+ * Android Application Id unique to every android application.
78
+ * See more in [[https://developer.android.com/build/configure-app-module#set-application-id ]]
81
79
*/
82
80
def androidApplicationId : String
83
81
@@ -92,19 +90,15 @@ trait AndroidAppModule extends AndroidModule { outer =>
92
90
* TODO dynamically add android:debuggable
93
91
*/
94
92
override def androidManifest : T [PathRef ] = Task {
95
- val manifestFromSourcePath = moduleDir / " src/main/AndroidManifest.xml "
93
+ val manifestFromSourcePath = androidManifestLocation().path
96
94
97
95
val manifestElem = XML .loadFile(manifestFromSourcePath.toString())
98
96
// add the application package
99
97
val manifestWithPackage =
100
- manifestElem % Attribute (None , " package" , Text (androidApplicationNamespace), Null )
101
-
102
- val manifestWithUsesSdk = manifestWithPackage.copy(
103
- child = androidManifestUsesSdkSection() ++ manifestWithPackage.child
104
- )
98
+ manifestElem % Attribute (None , " package" , Text (androidNamespace), Null )
105
99
106
100
val generatedManifestPath = Task .dest / " AndroidManifest.xml"
107
- os.write(generatedManifestPath, manifestWithUsesSdk .mkString)
101
+ os.write(generatedManifestPath, manifestWithPackage .mkString)
108
102
109
103
PathRef (generatedManifestPath)
110
104
}
@@ -294,6 +288,10 @@ trait AndroidAppModule extends AndroidModule { outer =>
294
288
s " version_code= ${androidVersionCode()}" ,
295
289
" --property" ,
296
290
s " version_name= ${androidVersionName()}" ,
291
+ " --property" ,
292
+ s " package= ${androidApplicationId}" ,
293
+ " --manifest-placeholders" ,
294
+ s " applicationId= ${androidApplicationId}" ,
297
295
" --out" ,
298
296
mergedManifestPath.toString()
299
297
) ++ libManifests.flatMap(m => Seq (" --libs" , m.path.toString())),
@@ -671,7 +669,7 @@ trait AndroidAppModule extends AndroidModule { outer =>
671
669
" am" ,
672
670
" start" ,
673
671
" -n" ,
674
- s " ${androidApplicationNamespace }/ ${activity}" ,
672
+ s " ${androidApplicationId }/ ${activity}" ,
675
673
" -W"
676
674
)
677
675
).out.lines()
@@ -683,7 +681,7 @@ trait AndroidAppModule extends AndroidModule { outer =>
683
681
*/
684
682
def androidReleaseKeyPath : T [Seq [PathRef ]] = {
685
683
val subPaths = androidReleaseKeyName.map(os.sub / _).toSeq
686
- Task .Sources (subPaths : _ * )
684
+ Task .Sources (subPaths* )
687
685
}
688
686
689
687
/*
@@ -1057,7 +1055,7 @@ trait AndroidAppModule extends AndroidModule { outer =>
1057
1055
override def androidSdkModule : ModuleRef [AndroidSdkModule ] = outer.androidSdkModule
1058
1056
override def androidManifest : T [PathRef ] = outer.androidManifest()
1059
1057
1060
- override def androidApplicationId : String = outer.androidApplicationId
1058
+ override def androidApplicationId : String = s " ${ outer.androidApplicationId} .test "
1061
1059
1062
1060
override def androidApplicationNamespace : String = s " ${outer.androidApplicationNamespace}.test "
1063
1061
@@ -1086,7 +1084,7 @@ trait AndroidAppModule extends AndroidModule { outer =>
1086
1084
1087
1085
override def resolutionParams : Task [ResolutionParams ] = Task .Anon (outer.resolutionParams())
1088
1086
1089
- override def androidApplicationId : String = s " ${outer.androidApplicationId}"
1087
+ override def androidApplicationId : String = s " ${outer.androidApplicationId}.test "
1090
1088
override def androidApplicationNamespace : String = s " ${outer.androidApplicationNamespace}.test "
1091
1089
1092
1090
override def androidReleaseKeyAlias : T [Option [String ]] = outer.androidReleaseKeyAlias()
@@ -1105,7 +1103,7 @@ trait AndroidAppModule extends AndroidModule { outer =>
1105
1103
1106
1104
private def androidInstrumentedTestsBaseManifest : Task [Elem ] = Task .Anon {
1107
1105
< manifest xmlns: android= " http://schemas.android.com/apk/res/android" package= {
1108
- androidApplicationNamespace
1106
+ androidApplicationId
1109
1107
}>
1110
1108
{androidManifestUsesSdkSection()}
1111
1109
</manifest >
@@ -1129,7 +1127,6 @@ trait AndroidAppModule extends AndroidModule { outer =>
1129
1127
val destManifest = Task .dest / " AndroidManifest.xml"
1130
1128
os.write(destManifest, manifestWithInstrumentation.toString)
1131
1129
PathRef (destManifest)
1132
-
1133
1130
}
1134
1131
1135
1132
override def androidVirtualDeviceIdentifier : String = outer.androidVirtualDeviceIdentifier
0 commit comments