java - Groovy in android - launcher activity cant be found -


i'm trying run simple android program. issue launcher activity groovy file, it's called mainactivity.groovy , resides in java source folder. here photo of gradle dependencies , project structure:

enter image description here

and here android manifest file:

<?xml version="1.0" encoding="utf-8"?> 

<application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name=".mainactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application> 

and lastly here error when run program:

07-08 17:11:49.297  20173-20173/com.example.uen229.myrxjavaandroidproject2 e/androidruntime﹕ fatal exception: main process: com.example.uen229.myrxjavaandroidproject2, pid: 20173 java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.uen229.myrxjavaandroidproject2/com.example.mainactivity}: java.lang.classnotfoundexception: didn't find class "com.example.mainactivity" on path: dexpathlist[[zip file "/data/app/com.example.uen229.myrxjavaandroidproject2-1/base.apk"],nativelibrarydirectories=[/vendor/lib, /system/lib]]         @ android.app.activitythread.performlaunchactivity(activitythread.java:2209)         @ android.app.activitythread.handlelaunchactivity(activitythread.java:2360)         @ android.app.activitythread.access$800(activitythread.java:144)         @ android.app.activitythread$h.handlemessage(activitythread.java:1278)         @ android.os.handler.dispatchmessage(handler.java:102)         @ android.os.looper.loop(looper.java:135)         @ android.app.activitythread.main(activitythread.java:5221)         @ java.lang.reflect.method.invoke(native method)         @ java.lang.reflect.method.invoke(method.java:372)         @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899)         @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694)  caused by: java.lang.classnotfoundexception: didn't find class "com.example.mainactivity" on path: dexpathlist[[zip file "/data/app/com.example.uen229.myrxjavaandroidproject2-1/base.apk"],nativelibrarydirectories=[/vendor/lib, /system/lib]]         @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56)         @ java.lang.classloader.loadclass(classloader.java:511)         @ java.lang.classloader.loadclass(classloader.java:469)         @ android.app.instrumentation.newactivity(instrumentation.java:1065)         @ android.app.activitythread.performlaunchactivity(activitythread.java:2199)             at android.app.activitythread.handlelaunchactivity(activitythread.java:2360)             at android.app.activitythread.access$800(activitythread.java:144)             at android.app.activitythread$h.handlemessage(activitythread.java:1278)             at android.os.handler.dispatchmessage(handler.java:102)             at android.os.looper.loop(looper.java:135)             at android.app.activitythread.main(activitythread.java:5221)             at java.lang.reflect.method.invoke(native method)             at java.lang.reflect.method.invoke(method.java:372)             at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899)             at com.android.internal.os.zygoteinit.main(zygoteinit.java:694) suppressed: java.lang.classnotfoundexception: com.example.mainactivity         @ java.lang.class.classforname(native method)         @ java.lang.bootclassloader.findclass(classloader.java:781)         @ java.lang.bootclassloader.loadclass(classloader.java:841)         @ java.lang.classloader.loadclass(classloader.java:504)         ... 13 more  caused by: java.lang.noclassdeffounderror: class not found using boot class loader; no stack available 

i have tried restarting pc , ide. keep in mind mainactivity has been renamed mainactivity.groovy. doing wrong ?

update: after following instructions here

i made directory structure looked following resolved issue:

enter image description here

in code have many problems:

  • groovy files should under groovy folder, not java
  • android not support groovy native language, java, need pre-compile groovy files in order let dalvik/art execute it. way applying plugin in build.gradle work you.

this great tutorial plugin on github.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -