java.lang.NoClassDefFoundError in AIDL Service - android

I have a problem with a set of AIDL services.
I have an Android application that contains the AIDL files in a packet called
es.mypackage.services. These AIDL files are well defined and they have the correct names.
In addition, this package contains the implementations of these AIDL file.
These java implementations are defined in the manifest as services.
After compiling, a package es.mypackage.services is created in the gen folder.
Apart from this android application I have another app that it's just a client of these services. In this app, I have a package also called es.mypackage.services that contains the same AIDL files. After compiling, a package es.mypackage.services is created in the gen folder.
Then, I run the "server" application in a device. Then, I also run the "client" in the same device obtaining the following error in LogCat:
java.lang.NoClassDefFoundError: es.mypackage.services.MyService
ERROR/AndroidRuntime(3499):at es.mypackage.services.MyService.onBind(MyService.java:26)
Well, the code of this line nº26 is "return new IMyService.Stub()" that is inside:
#Override
public IBinder onBind(Intent arg0)
{ return new IMyService.Stub()
{ ….
I don't know what is happening. Had somebody the same problem? Thanks in advance.

Related

Android DataBinding No field device of type I in class L***/****/common/BR

I have a project were I'm trying to share common code between different apps that will be contained.
Right now I only have a common module as an android library where I moved a single fragment and all his linked resources so I can used it on my main application module.
I'm able to display the layout correctly, but when I'm trying to bind a variable to this layout I'm getting the following error:
java.lang.NoSuchFieldError: No field device of type I in class L***/****/common/BR; or its superclasses (declaration of '**.****.common.BR' appears in /data/app/***.****.******-9VGDieZHqLKJUD0xhdmawA==/split_lib_slice_6_apk.apk)
Looking at the stack trace the issue happens on my fragment generated data binding class in this method:
public void setDevice(#Nullable **.***.common.vo.Device Device) {
this.mDevice = Device;
synchronized(this) {
mDirtyFlags |= 0x1L;
}
notifyPropertyChanged(BR.device);
super.requestRebind();
}
Specifically in this call: notifyPropertyChanged(BR.device).
So apparently the generated class cannot find the BR.device in the merged BR file, but it also stays that it was found in a split APK...
I don't know if this is a configuration issue or a bug in the merge process...
Any help will be appreciated.
Check if the package names for both modules are the same.
I had similar error and it was due to my lib module having the
same package name as my app module.
Example:
com.app.example (app module package name)
com.app.example (lib module package name)
I changed to this:
com.app.example (app module package name)
com.lib.example (lib module package name)

Android AIDLTokenType.IDENTIFIER expected, got rpc error in AIDL file

I have such aidl file:
package com.my.service;
import com.my.common.rpc.OnNextListener;
interface IService {
oneway void acceptStateListener(in OnNextListener l);
}
And I got an error in my Android Studio:
AIDLTokenType.IDENTIFIER expected, got 'rpc'
What's wrong here? Where I can find definitive tutorial about AIDL syntax?
It seems issue with the string "rpc" in your package name. Please rename it, it should work fine. I got similar error for the string "in" in my package.

Module with ContentProvider

I'm ussing this library, the problem starts with:
Tray is based on a ContentProvider. A ContentProvider needs a unique
authority. When you use the same authority for multiple apps you will
be unable to install the app due to a authority conflict with the
error message:
Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
because i didn't read this before, i used this library to fix problems with multi thread SharedPreference, this project had to become in a module to use in multiple projects.
At the moment of installing every App with this Module, throws the Failure [INSTALL_FAILED_CONFLICTING_PROVIDER] exception.
Because authority is already used in the first installed app.
The questions are:
How can i skip installation of Module that is already installed? (Installing the rest of the app, so error will disapear)
else, How can i structure the projects? to be able to install multiple apps built with the Module that have the ContentProvider Library.
Fixed
For those that need something similar these are the steps to follow:
Step 1. I configured Tray Library in a Main Project "required for the rest of apps"
(the app that hosts database preferences)
Step 2. I extracted from repository the required classes to connect with the Tray ContentProvider, which are:
AbstractTrayPreference.java
ContentProviderStorage.java
ItemNotFoundException.java
Migration.java
OnTrayPreferenceChangeListener.java
PreferenceAccessor.java
Preferences.java
PreferenceStorage.java
SqliteHelper.java
TrayContract.java
TrayDBHelper.java
TrayException.java
TrayItem.java
TrayPreferences.java
TrayProviderHelper.java
TrayRuntimeException.java
TrayStorage.java
TrayUri.java
WrongTypeException.java
in a new package for the common Module.
Step 3. I hardcoded authority name via constant variable:
This must match with Main Project configuration:
// bild.gradle of Main Project
resValue "string", "tray__authority", "<your.app.package>.tray"
// TrayContract.java of Module
#NonNull
private static String getAuthority(#NonNull final Context context) {
return TextUtils.isEmpty(sTestAuthority) ?
AppConstant.TRAY_AUTHORITY: // <-- this one = <your.app.package>.tray
sTestAuthority;
}
Finally I can use the class normally:
// etc
import <your.app.package>.tray.TrayPreferences;
// etc
public class AppPreferencesManager extends TrayPreferences {
// etc
}
it worked :)

Monodroid issue with jar binding zubhium sdk

Iam trying to bind a jar(zubhium sdk jar) file to my mono droid project. I have followed their guide on xamarins website and created a new binding project which I reference I my mono droid project.
I am having some issues with package names. I get the following error:
Error 3 package com.zubhium.interfaces does not exist
com.zubhium.interfaces.ZubhiumListener
C:\Users\jbp\Desktop\ny\CmsApp.Droid\obj\Debug\android\src\mono\com\zubhium\interfaces\ZubhiumListenerImplementor.java 8 25 CmsApp.Droid
from the genrated source:
package mono.com.zubhium.interfaces;
public class ZubhiumListenerImplementor
extends java.lang.Object
implements
mono.android.IGCUserPeer,
com.zubhium.interfaces.ZubhiumListener
And that is because when the project is wrapped it automaticly adds mono(.com.zubhium....) to the package name. I cant find how to remove this mono or if i can set a rule to add this part.
I tried to put <attr path="/api/package[#name='com.zubhium.interfaces']" name="managedName">mono.com.zubhium.interfaces</attr>
in the xmldata.xml file but that did not work.
Do you guys have any sugestions?
Regards
package com.zubhium.interfaces does not exist
When you bind a .jar library and reference the binding project from another project, you need to also add the .jar to your Application project and set its Build action to AndroidJavaLibrary.
Failure to do so means that the .jar won't be added to the javac $CLASSPATH, resulting in javac compilation errors when compiling the Android Callable Wrapper (as you saw), and that the .jar won't included into your final .apk. Both of these are Bad™.
And that is because when the project is wrapped it automaticly adds mono(.com.zubhium....) to the package name.
That's for an "Implementor" type; you can ignore it. It's used as part of the implementation of events. If you look at the generated C# code, there should be:
[global::Android.Runtime.Register ("mono/com/zubhium/interfaces/ZubhiumListenerImplementor")]
internal sealed class ZubhiumListenerImplementor : Java.Lang.Object, IZubhiumListener {
// ...
}
The mono.com.zubhium.interfaces.ZubhiumListenerImplementor is the ACW for the internal ZubhiumListenerImplementor type.
You can't rename this type; it's an internal construct that isn't controlled via metadata.

Android:Eclipse won't recognize AIDL file

I've looked and looked, but Eclipse (3.6, with the 2.2 Android SDK) just won't do anything with the AIDL file I created. The AIDL file is in the same place as the other source, following the Java style. I've read that Eclipse should just generate the stub for the interface declared in the AIDL file, but it doesn't appear in the gen folder, nor anywhere else i've seen, and the project doesn't build because the interface specified in the AIDL isn't found. I suspect i'm doing something silly or not understanding something, but as much as i've looked and tried, I still don't get it and Eclipse still fails.
My AIDL:
package com.example.helloandroid;
interface HOSPlayerInterface
{
public void playURL(String url);
public boolean pause();
public boolean resume();
public void stop();
}
... and said AIDL lives in the com/example/helloandroid directory. Eclipse isn't recognizing it, highlighting syntax, running AIDL, etc. I'm at a loss. The Android plugin is installed and working, as i'm able to build and run simple Android projects that don't require AIDL. Any help would be appreciated.
Just remove all "public" access modifier before method declaration. The following code works in my project.
package com.example.helloandroid;
interface HOSPlayerInterface {
void playURL(String url);
boolean pause();
boolean resume();
void stop();
}
If the aidl file can not get compiling in Eclipse, delete "gen" folder and rebuild the project.
Any build errors? The IDE might exit prior to compiling your .aidl-file due to parse errors in XML or similar.

Categories

Resources