Reputation: 11
So I'm trying to create Air Native extension that will get data from server in the background and then display notification. I'm already tried it on normal android application and it worked.
But when I try to make it as ANE it didn't work because somehow the code can't find volley (anything else is fine, including the background service)
Logcat result:
--------- beginning of crash
03-27 10:46:23.640 3680 3680 E AndroidRuntime: FATAL EXCEPTION: main
03-27 10:46:23.640 3680 3680 E AndroidRuntime: Process: air.bg, PID: 3680
03-27 10:46:23.640 3680 3680 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/volley/toolbox/Volley;
03-27 10:46:23.640 3680 3680 E AndroidRuntime: at com.company.backgroundprocess.JobSchedulerService.onStartJob(JobSchedulerService.java:54)
And here is the JobScheduler.java:
@Override
public boolean onStartJob(JobParameters jobParameters) {
parameters = jobParameters;
settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
unixTimeLastNotificationOnDevice = settings.getLong("lastNotificationTime", System.currentTimeMillis() / 1000);
//Line 54 bellow
queue = Volley.newRequestQueue(getApplicationContext());
mJobHandler.sendMessage(Message.obtain(mJobHandler, 1, jobParameters));
return true;
}
And that line caused error, which actually worked in normal android application, but unfortunately not in ANE
So I tried analyze the .apk with Android Studio and I find it included, which you can see on my screenshot here. And it's weird since the code can't find it.
Additional information, platform.xml I used:
<platform xmlns="http://ns.adobe.com/air/extension/13.0">
<packagedDependencies>
<packagedDependency>support-compat-26.1.0-sources.jar</packagedDependency>
<packagedDependency>volley-1.1.0-sources.jar</packagedDependency>
</packagedDependencies>
</platform>
Upvotes: 1
Views: 121
Reputation: 809
Are you using Maven or Gradle ? For Gradle check if you have
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/volley.jar')
}
for Maven check if you have
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r6</version>
</dependency>
<dependency>
<groupId>com.android.volley</groupId>
<artifactId>volley</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.mcxiaoke.volley</groupId>
<artifactId>library</artifactId>
<version>1.0.0</version>
</dependency>
In your ecplise double check if someother jar is conflicting com.android.volley.toolbox.Volley.class
(Press Ctrl+Shift+T and search with Volley). If so, resolve the dependencies.
Open a command prompt (or terminal) and navigate to your project directory. Run :
gradlew.bat clean
Reload Android Studio
References here
Upvotes: 1