I am integrating youtube in my android app. I am using gdata youtube library for the same.
`
YouTubeManager ym = new YouTubeManager(clientID);
List<YoutubeVideo> videos;
try {
videos = ym.retrieveVideos(textQuery, maxResults, filter, timeout);
for (YoutubeVideo youtubeVideo : videos) {
System.out.println(youtubeVideo.getWebPlayerUrl());
System.out.println("Thumbnails");
for (String thumbnail : youtubeVideo.getThumbnails()) {
System.out.println("\t" + thumbnail);
}
System.out.println(youtubeVideo.getEmbeddedWebPlayerUrl());
System.out.println("************************************");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} `
I have imported jar's as under,
activation.jar
apache-mime4j-0.6.jar
gdata-core-1.0.jar
gdata-media-1.0.jar
gdata-youtube-2.0.jar
google-collect-1.0-rc2.jar
httpmime-4.0.3.jar
mail.jar
servlet.jar
Now I am getting an exception SAXNotRecognizedException at
videos = ym.retrieveVideos(textQuery, maxResults, filter, timeout);
plz can any one tell me what is happening wrong over here. How to fix this error? Or any other way to integrate youtube in android app.
The root cause is reported as Issue 9493.
http://code.google.com/p/android/issues/detail?id=9493
And a workaround for it can be found here:
http://darutk-oboegaki.blogspot.com/2011/11/solution-for-gdata-java-clients.html
SecureGenericXMLFactory in gdata-core intentionally disables some features, but some of them are needed to retrieve data from YouTube. The basic idea of the work around is as follows.
(1) Remove the original SecureGenericXMLFactory from gdata-core-1.0.jar
cd gdata-src.java-1.46.0/gdata/java/lib
mkdir gdata-core-1.0-no-SecureGenericXMLFactory
cd gdata-core-1.0-no-SecureGenericXMLFactory
jar xf ../gdata-core-1.0.jar
rm -rf com/google/gdata/util/common/xml/parsing
jar cfm ../gdata-core-1.0-no-SecureGenericXMLFactory.jar META-INF/MANIFEST.MF com
(2) Replace the original gdata-core-1.0.jar with the new one created by the step (1). (in Eclipse)
(3) Copy the original source code of SecureGenericXMLFactory to your Android project.
(4) Add an unconditional 'return' in the constructor of SecureSAXParserFactory before the code lines that disable the necessary features.
// "if (true)" was added to avoid a compilation error in Eclipse.
if (true)
{
return;
}
Related
I am using Apollo Client in Android Project. I have 2 schema file and I have put them 2 different directories.
src/main/graphql/com/example/data/search/schema.json
src/main/graphql/com/example/data/user/schema.json
But when I build a project to generate code by Apollo It gives me an error:
ApolloGraphQL: By default, only one schema.json file is supported.
and suggest me to use multiple service
Build output:
ApolloGraphQL: By default, only one schema.json file is supported. Please use multiple services instead:
apollo {
service("search") {
sourceFolder = "/.../app/src/main/graphql/com/example/data/search"
}
service("customer") {
sourceFolder = "/.../app/src/main/graphql/com/example/data/customer"
}
}
I have also added this to my build.gradle(app level) file but still shows the same build error.
Please suggest me how can I solve this error
My Problem was resolved with this configuration
apollo {
// configure ApolloExtension here
generateKotlinModels.set(false) // Generate Kotlin models for all services
service("search") {
sourceFolder.set("com/example/data/search")
rootPackageName.set("com.example.data.search")
}
service("customer") {
sourceFolder.set("com/example/data/customer")
rootPackageName.set("com.example.data.customer")
}
onCompilationUnit {
// Overwrite some options here for single CompilationUnit if needed
}
}
Hope this may help others
I am trying to embed HereMap into my project. But I had encounter the following errors:
ERROR: Cannot initialize Map Fragment,MISSING_LIBRARIES,Library /data/user/0/my_project_package/files/../lib/libMAPSJNI.so not found.,java.lang.Throwable
I: at com.nokia.maps.at.a(EngineError.java:27)
I: at com.nokia.maps.MapsEngine.b(MapsEngine.java:367)
I: at com.nokia.maps.MapsEngine.a(MapsEngine.java:343)
I: at com.here.android.mpa.common.MapEngine.init(MapEngine.java:129)
I: at com.nokia.maps.br.a(MapFragmentImpl.java:126)
I: at com.here.android.mpa.mapping.MapFragment.init(MapFragment.java:132)
Following are the codes to use HereMap:
gmMapFragment = new MapFragment();
activity.getFragmentManager().beginTransaction().add(gmCenterView.getId(), gmMapFragment, "here_map_fragment").commit();
gmMapFragment.init(activity, new OnEngineInitListener() {
#Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == OnEngineInitListener.Error.NONE) {
gmMapFragment.getMapGesture().addOnGestureListener(gestureListener);
// Exceptions are thrown here!!!
gmMap = gmMapFragment.getMap();
....
}
}
};
I think I figure out what's wrong myself. It's that I didn't copy the "armeabi-v7a" folder with lots of .so files into the "jniLib" folder of my project. Sorry, I am pretty new on this.
thanks for the response.
Following are my steps of adopting Here Map into my project:
Step 1. Put the "HERE-sdk.jar" (also "HERE-sdk.jar.properties", "HERE-sdk-javadoc.jar") into the "lib" directory of my Android Studio project.
Step 2. Add the following setup in the build.gradle:
dependencies {
...
compile files('libs/HERE-sdk.jar')
...
}
Yes that link was the instructions we followed when we started the Here Map coding. The "gmCenterView" is actually a "RelativeLayout" that we will put the map fragment on.
public class MyView extends RelativeLayout {
...
}
MyView gmCenterView = ...
Please upgrade to the latest SDK. We have switched our deployment methods with AAR files which bundle both the Jar and native libraries together.
What you have provided above will only include the jar library. You still need to add the native binaries to the gradle file for it to work.
my question is simple enough. I am using Gluon's plugin for Eclipse and developing an application in JavaFX to run on Android. However, I need to use an Android library (.aar format) and after a while of trying, cannot. Does anybody know how I can do this? I have already tried just using the classes.jar inside the .aar, while this has sort of worked, there are a few resources and things I believe the library is missing that is essential to its function. Thank you.
Edit: The library I'm trying to use is CloudRail, the download is here (Direct download)
Currently, using the classes from the extracted classes.jar it is somewhat functional but when the activity from their library is launched (com.cloudrail.si.servicecode.commands.awaitCodeRedirect.AuthenticationActivity) it is displayed however it is blank and there is nothing in it. I am currently under the assumption that this is incorrect and that the missing resources/files are the cause of this.
I've managed to extract the classes.jar from the aar file and add it to a Gluon project as dependency.
Next, I added the activity to the AndroidManifest.xml file, after the main FXActivity:
<activity android:name="com.cloudrail.si.servicecode.commands.awaitCodeRedirect.AuthenticationActivity" />
Then I created a class in the Android package, provided the required credentials to access to Google Drive.
public AndroidTestAar() {
GoogleDrive cs = new GoogleDrive(FXActivity.getInstance(), "****","****");
new Thread() {
#Override
public void run() {
List<CloudMetaData> metas = cs.getChildren("/");
Log.i("info", "Folder has " + metas.size() + " children");
for (CloudMetaData meta : metas) {
Log.i("info", "Child: " + meta.getName());
}
}
}.start();
}
This class is called from the View:
public BasicView(String name) {
...
button.setOnAction(e -> {
try {
Class c = Class.forName("com.testaar.AndroidTestAar");
c.newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {}
});
}
I could deploy the apk and run it.
The activity runs outside the JavaFX app, in an Android WebView.
First it asked me to sign in with my user/password, then it asked me about allowing offline access, and finally on the console it successfully listed all my files.
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.
I keep getting this error (Upgrading old nbandroid project projectName FAILED. See log file for details.) for a few android projects in Netbeans. I'm not sure where to find the log the message refers to, I have checked every log I can find both in netbeans & system logs. To no avail, no more information.
I tried tracking down the score code and see what generates this error, I found this code (here: https://code.google.com/p/nbandroid/source/browse/project/src/org/netbeans/modules/android/project/AndroidProjectUtil.java?name=v1.5beta&r=d12ce88eb7d6a04ac55d0ae2bd8813fea1651bb4)
private static AndroidGeneralData findSDKAndTarget(
AndroidProject project, PropertyProvider props, FileObject nbproject) {
String platformName = props.getProperties().get("platform.active");
if (platformName == null) {
LOG.log(Level.INFO, "Cannot upgrade old nbandroid project. platform definition not found in project.properties");
return null;
}
FileObject storage = FileUtil.getConfigFile(PLATFORM_STORAGE);
String buildTargetPath = null;
if (storage != null) {
for (FileObject platformProvider : storage.getChildren()) {
buildTargetPath = parseIfActivePlatorm(platformProvider, platformName);
if (buildTargetPath != null) {
break;
}
}
}
if (buildTargetPath == null) {
LOG.log(Level.INFO, "Cannot upgrade old nbandroid project. platform {0} not found", platformName);
return null;
}
DalvikPlatform platform = toDalvikPlatorm(buildTargetPath);
if (platform == null) {
LOG.log(Level.INFO, "Cannot upgrade old nbandroid project. platform {0} not found in Android SDK", platformName);
return null;
}
AndroidGeneralData data = new AndroidGeneralData();
data.setPlatform(platform);
data.setProjectDirPath(project.getProjectDirectoryFile().getAbsolutePath());
data.setProjectName(project.getLookup().lookup(ProjectInformation.class).getName());
return data;
}
Leaving pretty much 3 possibilities, I have tried looking for all these, and as far as I can tell the data is present for all 3. I checked the project.properties, genfiles.properties and project.xml files, I would be happy to supply these if necessary.
Any tips or advice would be greatly appreciated, the projects work at the moment, but I would like to get rid of the annoying messages at start up.
I have now managed to track down the exact fault. The log file mentioned was well hidden in the netbeans directories (which had also changed place in netbeans 7.2).
I need the platform files in [netbeans file root]/config/services/platforms/org-netbeans-api-java-Platform
These are no longer available in anyway I can find, I also checked all old developer computers we have.
If someone has these platform files (I suspect they are xml files, from what I found) it would be greatly appreciated if they could send them to me. I should be able to modify them to make them work.
It seems that the project update process failed to load Java Platform definition from a file that is somewhere in your netbeans userdir - http://wiki.netbeans.org/FaqWhatIsUserdir As a result it cannot set Android SDK location and find what is the target platform for your project. It is possible that the file/the settings was lost when you upgraded your IDE or for some other reason.
My suggestion is that you migrate your project manually. There is a hint in http://www.nbandroid.org/2011/02/beta-build-of-new-project-support.html
remove nbproject directory and create an Android project as described in http://developer.android.com/tools/projects/projects-cmdline.html. NBAndroid recognizes this project structure and will be able to work with it. Or create this project in an empty directory and move your sources + resources there.
-Radim