I am attempting to develop a "Dynamic" Android application.
Dynamic in the sense that I have an activity listed in the manifest that is "built" at runtime.
I can build the required activity fine, however, when I attempt to start it my application fails with...
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.research.ps/com.research.Dynamic}: java.lang.ClassNotFoundException:
Didn't find class "com.research.Dynamic" on path: DexPathList[[zip file "/data/app/com.research.ps-1/base.apk"],nativeLibraryDirectories=[/data/app/com.research.ps-1/lib/arm,
/data/app/com.research.ps-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
Is there an approach I can take to successfully instantiate an Android Activity at runtime?
Is there a way I can add a "temporary" or "shell" activity onto my application path? and then replace the "temporary" activity with my dynamic instance?
UPDATE
My Manifest XML contains this entry
<activity
android:name=".Dynamic"
android:label="@string/title_activity_dynamic"
android:theme="@style/AppTheme.NoActionBar" />
However, there is no Activity called "Dynamic" contained within my application.
I am using ByteBuddy to build my dynamic activity:-
final Class<? extends android.support.v7.app.AppCompatActivity> dynamicType = new ByteBuddy(ClassFileVersion.JAVA_V8)
.subclass(android.support.v7.app.AppCompatActivity.class, IMITATE_SUPER_CLASS)
.name("com.research.Dynamic")
.make()
.load(getClass().getClassLoader(), new AndroidClassLoadingStrategy.Wrapping(this.getDir("dexgen", Context.MODE_PRIVATE)))
.getLoaded();
final Intent intent = new Intent(this, dynamicType);
startActivity(intent);