I have 1 project based on this: https://github.com/Nilhcem/i2cfun-androidthings
https://github.com/neuberfran/SmartDrive5 (the latter is my project)
But, when I change PeripheralManagerService to PeripheralManager (DP 7 and APi level 27)
try {
PeripheralManager manager = PeripheralManager.getInstance();
mDevice = manager.openI2cDevice(I2C_DEVICE_NAME, I2C_ADDRESS);
} catch (IOException e) {
Log.w(TAG, "Unable to access I2C device", e);
}
I have this issue: https://drive.google.com/file/d/1kXfknYcu4RUF7AT1549_sjJiVSG2_Jjo/view?usp=sharing in this line: https://drive.google.com/file/d/1nTXOV0qiQDe5XldzIuLsY26oIdyfs3x3/view?usp=sharing
I know about this: PeripheralManagerService throws NoClassDefFoundError
but not solved.
Can you help me
The class not found exception means that peripheral manager is not on the operating system. You are trying to use a new API on a device that has an older version.
You need to have the Android things library dependency in sync with the version installed on your device.
And as it has been suggested, you should get everything into the stable release.
Related
recently I ported my old Android game developed in Eclipse from 2011-2016, to Android Studio because I was forced to a much higher MinSdk by Google. To the following according to build.gradle:
compileSdk 30
minSdk 26
targetSdk 31
Everything worked fine after the porting, but I am not able to get the GooglePlayServices (Leaderboards, Achievements) working again.
I am able to trigger that the user signs in with it GooglePlay account. This works and I get the account and can log its name. That is working.
mGoogleSignedInAccount = completedTask.getResult(ApiException.class);
Log.e(TAG, "account: " + mGoogleSignedInAccount.getDisplayName());
But when I try open the leaderboard, so that the user can see their highscore compared to other players
LeaderboardsClient lbc = Games.getLeaderboardsClient(v.getContext(),
ApplSettings.getInstance()._mainActivity).mGoogleSignedInAccount);
Task<Intent> lbt = lbc.getAllLeaderboardsIntent();
lbt.addOnSuccessListener(new OnSuccessListener<Intent>() {
public void onSuccess(Intent intent) {
Log.d(TAG," ..onSuccess");
((Activity) (v.getContext())).startActivityForResult( intent, 9004 );
}
});
lbt.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.d(TAG,".. onFailure: "+e.toString());
}
});
I get the following error:
.. onFailure: com.google.android.gms.common.api.ApiException:
17: API: Games.API is not available on this device.
Connection failed with: ConnectionResult{statusCode=DEVELOPER_ERROR, resolution=null, message=null}
I really don't understand this error. What does it mean? It is independent of the phones I use (OnePlus6T, Samsung Galaxy S9). And of course other game apps on those phones, including my other older games app, can show Leaderboards!
What is also strange, is the following message in the GooglePlayConsole of my app in Play-GamesSevice->Configuration.
It says the 5 tasks have to be done to enable the Play-GameServices, and its states that 4 have been done, and 1 task is remaing:
Play-GameService enabling:
Create a Play GamesService project -> done
Create OAuth ConfirmationScreen in the Google Cloud Platform -> done
Create Credentials -> done
Add the SDK for Google Play-GamesServices to your production APK -> OPEN !!!
Publish Project -> done
What does point 4 mean? How to add an SDK to my games app?
Is it not enough to mention those play-service 'libraries' in the build.gradle of my app?
buildscript {
repositories {
google()
mavenCentral()
}
}
dependencies {
. . .
implementation 'com.google.android.gms:play-services-games:23.1.0'
implementation 'com.google.android.gms:play-services-measurement-api:20.0.0'
implementation 'com.google.android.gms:play-services-auth:20.4.1'
}
So I am not sure if this task (number 4) mentioned by Google as outstanding, is related to the error "Games.API is not available on this device", but it would make sense.
But still I don't understand "not available on this device"? Does not the app is build with libraries that communicate with the Google services in the cloud? What shall be missing on the device? All games app (my other very old game, and also very new apps) can without problem show leaderboards on my devices I use for testing.
I have a node server which uses Let's Encrypt CA and it's hosted on zeit.now.
The client is developed using react-native.
I try to connect to it using websockets.
On iOS and newer Android versions (API > 20) it connects successfully.
When running on older Android versions (both on simulator and actual devices) it never connects.
I have tried to connect using older Android version to a server that's not using Let's encrypt CA (but IS using ssl from other provider - hosted on heroku), and it also connects successfully.
So I believe there is something wrong with older Android versions and Let's encrypt certificate.
Could someone help? I have lost 5 days researching this problem and I don't know a lot about JAVA.
EDIT:
I try to connect using websocket
ws.onerror = (e) => {
// an error occurred
console.log(e.message);
};
this logs:
Connection closed by peer
and this method:
ws.onclose = (e) => {
// connection closed
console.log(e.code, e.reason);
};
logs:
undefined, undefined
I fixed it! See this comment.
Basically I needed to install the latest security fixes that are bundled with Google Play Services
I fixed this by adding the following dependency to Gradle:
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
and then calling
public void onCreate() {
super.onCreate();
try {
ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {
// Don't forget exception handling!
} catch (GooglePlayServicesNotAvailableException e) {
// Do something clever
}
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
I'm programming an app in Android but I canĀ“t connect it to a local neo4j database.
In the gradle I've put this dependencies:
compile 'org.neo4j.driver:neo4j-java-driver:1.4.1'
compile 'org.neo4j:neo4j-jdbc:3.1.0'
The connection code is the following:
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
import static org.neo4j.driver.v1.Values.parameters;
public class ConsultasBD {
#TargetApi(Build.VERSION_CODES.KITKAT)
public static boolean consultaLogin(String u, String p) {
try {
// Connect
Driver driver = GraphDatabase.driver( "bolt://192.168.0.39:7474");
Session session = driver.session();
// Querying
StatementResult result = session.run( "MATCH (a:Person {usr: {name}, Pass: {pass}})",
parameters( u, p ) );
while ( result.hasNext() )
{
System.out.println("OK");
}
session.close();
driver.close();
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
}
But when I run it, I get this exception:
java.lang.NoClassDefFoundError:
Failed resolution of: Ljava/net/StandardSocketOptions;
And I don't know how can I fix it.
Can anyone explain me how can I connect my app with neo4j?
Thank you very much.
Miguel
StandardSocketOptions was only added to Android in API level 24 (Nougat). So, unless you have a device with API level 24 or higher, you will get that exception.
However, even if you do run your app on such a device, there may be other needed classes that are missing. This is because the neo4j Java libraries do not attempt to target the Android environment (which only supports part of the standard Java libraries). So, this kind of problem is to be expected. Android apps should use the neo4j HTTP API instead.
After upgrading to Android gradle plugin 2.2.0 (and Android Studio 2.2) I've been having trouble reading from a zip file which is located at app/src/main/assets/magic_info.zip It used to work fine with plugin versions 2.1.3 and prior but now it throws the following exception
java.io.FileNotFoundException: magic_info.zip
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:334)
at android.content.res.AssetManager.open(AssetManager.java:308)
for some reason it can't find the file from assets which is otherwise there.
Here is my code that used to work in the past.
public static ZipInputStream getZipInputStream(Context context)
{
try
{
return new ZipInputStream(context.getAssets().open("magic_info.zip"));
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
Any idea what's wrong with this? Am I missing something?
Replace this:
return new ZipInputStream(context.getAssets().open("magic_info.zip"));
with this:
return new ZipInputStream(getResources().getAssets().open("magic_info.zip"));
OK I've figured it out and it's kind of strange.
As of Android Studio 2.2 and gradle plugin 2.2 you are required to have the android SDK which corresponds to your testing device along with the target SDK installed on your machine if you want things to work properly.
Now I may target API 24 but I test my app to a device running lollipop (API 21). Once I installed SDK 21 the file is being read normally.
When I do this:
try {
workbook = new HSSFWorkbook(new FileInputStream(mInputFile))
} catch (Exception e) {
...
}
My android project work in debug time but crash in run time.
I Use apache POI 3.9
I suspect it could because of the missing java.rmi.UnexpectedException
Thanks Gagravarr..
As metioned on this http://poi.apache.org/changes.html link, "Avoid using RMI based exception from PropertySetFactory, as it's not needed nor helpful" is been fixed in Version 3.10-FINAL (2014-02-08).
Use, 3.10 Final or upper version to get rid of 'java.rmi.UnexpectedException' error.
It looks like a mistake in PropertySetFactory - there's no reason for it to be using a RMI exception, as there's no RMI involved. My hunch is that it's the RMI class that's confusing Android.
I've raised this as bug #55901, and it's fixed as of r1551832. If you grab a nightly build from tomorrow, or do a SVN checkout and build yourself, it ought to now be fixed.