title: Refactoring package name breaks app with ClassNotFoundException due to not finding the Application class even though it is there
body: <p>I <strong>had</strong> this package format:</p>
  
  <pre><code>com
    example
      name
        oldAppName
  </code></pre>
  
  <p><strong>Now</strong>, I refactored and renamed by Shift+F6 to <strong>this:</strong></p>
  
  <pre><code>com
    myCompanyName
      name
        newAppName
  </code></pre>
  
  <p>However,now when I run my app, I get this crash:</p>
  
  <pre><code>java.lang.ClassNotFoundException: Didn't find class "com.example.name.oldAppName.Application" on path: DexPathList[[zip file "/data/app/com.myCompanyName.name.newAppName1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
  </code></pre>
  
  <p>I have my <code>Application.java</code> under <code>newAppName</code>, and it is defined in the Manifest correctly
  <strong>What I tried and did were:</strong></p>
  
  <ul>
  <li><em>Cleaning and Rebuilding</em></li>
  <li>Changing <code>applicationId</code> in build.gradle</li>
  <li>The package name in manifest is correct and so are all the names of the App and Activities.</li>
  </ul>
  
  <p>In fact, here's my application manifest tag:</p>
  
  <pre><code>&lt;application
    android:name=".Application"
    ...
    &gt;
  </code></pre>
  
  <p><strong>Even changing <code>.Application</code> to the full package name (<code>com.blah.blah.Application</code>)</strong> <em>DIDN'T WORK.</em></p>
  
  <p>Am I missing something? Is there a missing step? </p>
  
  <p><strong>Here's the full log:</strong></p>
  
  <pre><code>    java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.IllegalStateException: java.lang.ClassNotFoundException: com.example.name.oldAppName.Application
        at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4345)
        at android.app.ActivityThread.access$1500(ActivityThread.java:135)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5045)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: com.example.name.oldAppName.Application
        at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:220)
        at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239)
        at android.app.Application.attach(Application.java:181)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1008)
        at android.app.Instrumentation.newApplication(Instrumentation.java:992)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) 
        at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5045) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
        at dalvik.system.NativeStart.main(Native Method) 
     Caused by: java.lang.ClassNotFoundException: com.example.name.oldAppName.Application
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:251)
        at java.lang.Class.forName(Class.java:216)
        at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:209)
        at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239) 
        at android.app.Application.attach(Application.java:181) 
        at android.app.Instrumentation.newApplication(Instrumentation.java:1008) 
        at android.app.Instrumentation.newApplication(Instrumentation.java:992) 
        at android.app.LoadedApk.makeApplication(LoadedApk.java:511) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) 
        at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5045) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
        at dalvik.system.NativeStart.main(Native Method) 
     Caused by: java.lang.NoClassDefFoundError: com.example.name.oldAppName/Application
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:251) 
        at java.lang.Class.forName(Class.java:216) 
        at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:209) 
        at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239) 
        at android.app.Application.attach(Application.java:181) 
        at android.app.Instrumentation.newApplication(Instrumentation.java:1008) 
        at android.app.Instrumentation.newApplication(Instrumentation.java:992) 
        at android.app.LoadedApk.makeApplication(LoadedApk.java:511) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) 
        at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5045) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
        at dalvik.system.NativeStart.main(Native Method) 
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.name.oldAppName.Application" on path: DexPathList[[zip file "/data/app/com.newCompanyName.name.newAppName-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myCompanyName.name.newAppName-1, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:251) 
        at java.lang.Class.forName(Class.java:216) 
        at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:209) 
        at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239) 
        at android.app.Application.attach(Application.java:181) 
        at android.app.Instrumentation.newApplication(Instrumentation.java:1008) 
        at android.app.Instrumentation.newApplication(Instrumentation.java:992) 
        at android.app.LoadedApk.makeApplication(LoadedApk.java:511) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4345) 
        at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5045) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
        at dalvik.system.NativeStart.main(Native Method) 
  </code></pre>