重构项目后,android studio生成旧路径

时间:2016-04-13 14:19:33

标签: android-studio refactoring

我做了一次重构,并在android studio中更改了我的应用程序的包名。此外,在清单中进行更改并更改项目文件夹名称。

我用'oldname'和'newname'替换文件名以使事情更清楚

但是没有Class.forName不再找到这个类

Class target = Class.forName("LoginScreen");
Intent goTo = new Intent(WelcomeScreen.this, target);
startActivity(goTo);

以上代码产量

04-13 14:03:08.375 5264-5264/? I/art: Not late-enabling -Xcheck:jni (already on)
04-13 14:03:08.613 5264-5264/com.example.ce.oldname W/System: ClassLoader referenced unknown path: /data/app/com.example.ce.oldname-2/lib/x86
04-13 14:03:08.992 5264-5270/com.example.ce.oldname W/art: Suspending all threads took: 8.440ms
04-13 14:03:09.036 5264-5292/com.example.ce.oldname D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-13 14:03:09.142 5264-5292/com.example.ce.oldname I/OpenGLRenderer: Initialized EGL, version 1.4
04-13 14:03:09.178 5264-5292/com.example.ce.oldname W/EGL_emulation: eglSurfaceAttrib not implemented
04-13 14:03:09.179 5264-5292/com.example.ce.oldname W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabf6a0c0, error=EGL_SUCCESS
04-13 14:03:10.047 5264-5289/com.example.ce.oldname W/System.err: java.lang.ClassNotFoundException: LoginScreen
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.Class.classForName(Native Method)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.Class.forName(Class.java:324)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.Class.forName(Class.java:285)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at com.example.ce.newname.WelcomeScreen$1.run(WelcomeScreen.java:36)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "LoginScreen" on path: DexPathList[[zip file "/data/app/com.example.ce.oldname-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.ce.oldname-2/lib/x86, /vendor/lib, /system/lib]]
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:   ... 4 more
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:   Suppressed: java.lang.ClassNotFoundException: LoginScreen
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.Class.classForName(Native Method)
04-13 14:03:10.048 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
04-13 14:03:10.049 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
04-13 14:03:10.049 5264-5289/com.example.ce.oldname W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
04-13 14:03:10.049 5264-5289/com.example.ce.oldname W/System.err:       ... 5 more
04-13 14:03:10.049 5264-5289/com.example.ce.oldname W/System.err:   Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
04-13 14:03:10.049 5264-5289/com.example.ce.oldname I/System.out: DEBUG:Menu
04-13 14:05:39.594 5264-5270/com.example.ce.oldname W/art: Suspending all threads took: 7.819ms
04-13 14:06:04.120 5264-5270/com.example.ce.oldname W/art: Suspending all threads took: 11.536ms

在模拟器上安装应用程序时,我在下面打印,表明它仍然使用带有oldname的路径来生成构建。

Installing APK: 
C:\Users\CE\AndroidStudioProjects\newname\app\build\outputs\apk\app-
debug.apk

Uploading file to: /data/local/tmp/com.example.ce.oldname
Installing com.example.ce.oldname
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.ce.oldname"
pkg: /data/local/tmp/com.example.ce.oldname

Android Studio如何决定设置此路径以及如何更改它以便应用程序以新名称运行?

0 个答案:

没有答案