We have a rather unique situation with our Android project, in that we use 
the same code base to build literally thousands of different apps, each 
with a different package name.

For the most part this hasn't been a problem. Recently I migrated our build 
system to Gradle and it is certainly functional, but we don't seem to be 
able to take advantage of some of the benefits of Gradle 2.0, specifically 
incremental builds and instant run.

NOTE: I am thinking these 2 issues are related, since if the correct 
package name is cached, incremental builds and instant run work fine.

1) For some reason, ALMOST every build I run cleans itself before it runs, 
even when no source is changed.
Executing tasks: [:app:clean, :app:generateDebugSources, :app:
mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:
generateDebugAndroidTestSources, :app:assembleDebug]

I'm assuming this is Gradle getting confused, but I have no idea how to 
troubleshoot what might be causing a clean to be triggered.

2) And this is completely tripping me out. I will build my app with this 
package name, and ADB installs it correctly:

*com.subsplash.thechurchapp.aaronchurch*

But it seems Android Studio caches the old one for a very long time, which 
results in an error like this...

$ adb shell am start -n 
"*com.subsplash.thechurchapp.freshlifechurch*/com.subsplash.thechurchapp.SplashActivity"
 
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "
*com.subsplash.thechurchapp.freshlifechurch*/com.subsplash.thechurchapp.SplashActivity"
 
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN 
cat=[android.intent.category.LAUNCHER] 
cmp=com.subsplash.thechurchapp.freshlifechurch/com.subsplash.thechurchapp.SplashActivity
 
}
Error type 3
Error: Activity class 
{*com.subsplash.thechurchapp.freshlifechurch*/com.subsplash.thechurchapp.SplashActivity}
 
does not exist.

Error while Launching activity

I have searched my whole machine for the text:
com.subsplash.thechurchapp.freshlifechurch

And I can't find it anywhere. I have purged caches, removed all build 
files, and the Android Studio preferences. Does anyone know where Android 
Studio is getting this package name from?

Also, quick note on how I am providing the package name. In build.gradle I 
am reading the package name from an API endpoint, and I am generating the 
Android manifest conditionally if the package name changes. 

json = new JsonSlurper().parseText(proc.text)

androidPackageName = json.android.package_name


android {
    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId androidPackageName
        minSdkVersion 10
        targetSdkVersion 22
        versionName project.tcaVersion
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = [project.SRC_DIR]
            res.srcDirs = [project.RES_DIR]
            assets.srcDirs = [project.ASSET_DIR]
            aidl.srcDirs = [project.SRC_DIR]
            renderscript.srcDirs = [project.SRC_DIR]
        }

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/6fc78005-4c52-4ef7-a5f9-e8b40b1dd08b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to