OData class not found when trying to access SQL Azure database - android

I am trying to create an android application to connect to Azure's SQL database. When I try to create a ODataConsumer object that would later be used to filter the message.
The ODataConsumer object is create with the create method
ODataConsumer c = ODataConsumer.create("http:/xxx/yyy.svc");
But when the execution reaches here, I get class def not found exception and the application is force closed.
I downloaded the jar files from the following site
http://code.google.com/p/odata4j/downloads/list
I started off with v0.3 as this is the jar file used in the demo that is provided by Microsoft. I also tried v0.4
I add <uses-permission android:name="android.permission.INTERNET"/> to the manifest file of the project. I also import
import org.odata4j.consumer.ODataConsumer;
import org.odata4j.core.OEntity;.
Am I missing something here?
The error that I get is AndroidRuntime(595): java.lang.NoClassDefFoundError: org.data4j.consumer.OdataConsumer

You should really be using the latest version.
Also the class name in the error is misspelled. It's ODataConsumer not OdataConsumer.

I was having the same problem. In my case I was able to follow the example here:
http://xrigau.wordpress.com/2012/03/22/fix-some-problems-with-libraries-in-the-adt-17-plugin-10/
which is described here:
Android-SDK r17 ruins working projects
which solved my problem. Good luck.

Related

Application is not Registered in react native

I have a react native application and I changed the package name of the application using https://www.npmjs.com/package/react-native-rename. After that I tried to run the project but its saying that the application is not registered. I have tried the following steps also.
Opened the project in android studio and make sure that the package name is changed and all the files are also in the same package name.
Tried cleaning the old gradle files.
Uninstalled the previously installed version of the app (The one which have the original package name.
Any help would be appreciated. Thanks in advance
You need to check 2 files to make sure you have equal names there:
index.js -> application name in the last line:
AppRegistry.registerComponent('YourAppName', () => App);
app.json -> name property
In both places names should be equal (case sensitive).
Have you changed the values ​​in the index.ios.js, index.android.js and app.json files?
There are some instructions here.
android\app\src\main\java\com{someFolderName}\MainActivity.java
you landed up on this answer because still you are not able to solve the issue
open the file mentioned in above in title
this used for
Returns the name of the main component registered from JavaScript.
This is used to schedule rendering of the component.
look for method
#Override
protected String getMainComponentName() {
return "AddYourNewNameHere";
}
which might be returning a hard coded string replace it to desired name!!
EXTENDED TIP
ensure you clean your gradle demon as the project does not compile sometimes
for that use following
cd android
gradlew clean

NativeScript Does Not Recognize "android.Manifest.permission.READ_CONTACTS"

Hello I am new to mobile development and Angular 2. I am trying to request permission for reading contacts, however NativeScript is not recognizing "android".
For exmple I am not able to run the following code:
permissions.requestPermission(android.Manifest.permission.INTERNET, "I need these permissions because I'm cool");
Error: Cannot find name 'android'.
Any help will be greatly appreciated.
At the top of your TS file just add:
declare var android: any;
TypeScript does not know what "android" is; so you have to tell it what it is
The other way to fix this is to download the platform typings
https://www.npmjs.com/package/tns-platform-declarations and then install them. Please note the Typings do typically slow down compilation as they add a lot of data that has to be parsed...
Disclaimer: I'm the author of the NativeScript-Permissions plugin you are using. ;-)

Cannot compile system app (Phone) using maven - EventLogTags cannot be resolved

this is related to my previous question. I'm trying to build Phone application from android 4.0.4 using maven (I'm adding framework_intermediates as dependency, so internal apis problems are solved), and I ran into this problem. Some parts of the logs are as follows:
Phone/src/com/android/phone/CallNotifier.java:[601,32] cannot find symbol
symbol : variable EventLogTags
(the corresponding line in CallNotifier.java is: EventLog.writeEvent(EventLogTags.PHONE_UI_MULTIPLE_QUERY); )
Phone/src/com/android/phone/InCallScreen.java:[723,28] cannot find symbol
symbol : variable EventLogTags
(the corresponding line in InCallScreen.java is: EventLog.writeEvent(EventLogTags.PHONE_UI_ENTER); )
So... it cannot find the class EventLogTags. There is actually a file Phone/src/com/android/phone/EventLogTags.logtags which has the following contents:
# See system/core/logcat/event.logtags for a description of the format of this file.
option java_package com.android.phone;
70301 phone_ui_enter
70302 phone_ui_exit
70303 phone_ui_button_click (text|3)
70304 phone_ui_ringer_query_elapsed
70305 phone_ui_multiple_query
Apparently, this file tells the system to use some particular tags to log important events in the system. I did a full grep, but could not find any file which defines the values PHONE_UI_ENTER, PHONE_UI_MULTIPLE_QUERY, etc. These are just logs, so I could just comment out these and get it working. But I don't want to do this because I need to build this inside the entire aosp later on. So my question is, how do I get this to compile using maven, without modifying any file?
The Android build system code-generates a Java class out of .logtags files if needed. See: https://github.com/android/platform_build/blob/master/core/base_rules.mk
You will need to decipher the make rules and run that code generation yourself, I imagine.

Android schema validation with xerces

I am trying to validate an xml file against an xsd schema file using Xerces. I am hitting errors that I am unable to resolve, below is the logcat output. Please note that trying the same code and xercesImpl.jar file in a java application produces accurate validation results but moving the same to android results in errors. Please advice.
E/AndroidRuntime(792): java.lang.NoClassDefFoundError: org.apache.xerces.parsers.SAXParser
Thanks..
The solution is to use Apache Xerces ported to Android.
There is a project here
You have to do a svn chekout and export the proyect to a jar file to use as a library in your android proyect.
The code to instance SchemaFactory change a little.
I show you an example:
import mf.javax.xml.validation.Schema;
import mf.javax.xml.validation.SchemaFactory;
import mf.javax.xml.validation.Validator;
import mf.org.apache.xerces.jaxp.validation.XMLSchemaFactory;
SchemaFactory factory = new XMLSchemaFactory();
Schema esquema = factory.newSchema(".../file.xsd");
The problem is that android doesn't have xerces and validating interface =)
But you can simply add validating from xerce:
You can use xerces and native schema validation (in java) in adnroid - you have to download xerces sources and (after some simple manipulations) include it to your own code - you will be able to use DocumentBuilderFactory.setShema method.
https://stackoverflow.com/questions/13142567/xml-schema-validation-xmlsignature-with-xerces-in-android

Android Project will not work with external JAR or Project Reference

I have a semester long project that I have been working on in Android with a four person group. It is due tomorrow. I was planning on using JDBC for Android, but I have run into an ugly problem I had seen before. No matter what I do, my Android will not recognize external references. For awhile I avoided the problem by copying source code into my project.
However, with JDBC, I need a JAR Driver to in order to connect to the MySQL Database. So you are aware, I am adding the JAR by:
Creating a folder
Importing the JAR into that folder
Adding the JAR to the BuildPath in the Android Project.
I also tried adding an external Java Project by adding it to the BuildPath. There were no Compile errors, but I got ClassNotFound errors when the code executed on my (Ice Cream Sandwich) phone. The project is in Android 2.2. I have heard making an Android Library project will solve this, but I am not interested in that solution as it defeats the purpose of the project reference in my case.
With the JDBC Driver, the following RuntimeException was thrown in my project here:
private final static String driver = "com.mysql.jdbc.Driver";
private final static String userName = "sqluser";
private final static String passwd = "sqlpw";
public Query() {
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
// System.err
// .println("error in DB connection: can not find the DB driver");
throw new RuntimeException("Driver not found");
}
The code works fine as a Java Application.
Any solution that works would be highly appreciated. Since the project is due tomorrow, it doesn't have to be the most elegant approach. Also (not that it matters), my project is connected to a SVN repository via SubClipse. Thanks in advance!
I'm unsure which folder you are putting the JAR in but for android projects you must put them inside of the folder "libs".

Categories

Resources