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.
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 wrote a library which has been uploaded to a private server. When I include the library as a dependency in my app project, and view the source code from one of the library classes, the source code isn't actually decompiled. It only shows the class name and methods. For example:
package com.example.library.ui
public final class RoundedDrawable public constructor() : android.graphics.drawable.Drawable {
public final var backgroundColor: kotlin.Int /* compiled code */
// ... other similar fields
public open fun draw(canvas: android.graphics.Canvas): kotlin.Unit { /* compiled code */ }
// ... other similar functions
}
As you can see, it only displays /* compiled code */ comments, and not the full source code. There is an option presented to "Decompile to Java"; which works, but I would much rather see the Kotlin source. Is this possible?
I found similar question that explains how to show the original Java code, but nothing for Kotlin.
Are you using Gradle?
You need to download sources for the library:
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
If attached sources/documentation are found, IntelliJ will use these when viewing .class files.
With Maven, you can do this from the tool window with Right click -> Download Sources
Other than that, decompiling a .class file to Kotlin is not possible with good results. Despector has a very rough Kotlin "decompiler".
When Releasing the library with maven publish, you can specify the source jar.
In this example, if your library is in Kotlin and Java, to add both source codes.
task androidSourcesJar(type: Jar) {
archiveClassifier = 'sources'
from (android.sourceSets.main.java.sourceFiles, android.sourceSets.main.kotlin.sourceFiles)
}
I have create .aar file from another project and added to new project.I have seen Classes are there but method name has changed.If i trying to access any method i have add in that class, got no method by that name. Finally I have seen method are like this.
public static void a(Context var0) {
if(var0 != null) {
var0.startService(new Intent(var0, TrackLocationOfficial.class));
}
}
method name has changed to a(), b(),c().
what to do?
is local .aar is working ?
It seems like your .aar was minified with proguard, this causes the methods to be renamed.
In the gradle file of your module you have enabled proguard, just disable that by
minifyEnabled false
You have to do it in your different configurations as in build and release separately
I have followed building instructions for tess-two on
Github
I build tess-two using NDK successfully and imported the library
I am trying to run the test application provided on the same repository but whenever the application starts it gives the following exception:
That error is caused once new TessBaseAPI(); is called.
dlopen("/data/app-lib/com.datumdroid.android.ocr.simple-2/liblept.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libpng.so" needed by "liblept.so"; caused by load_library(linker.cpp:745): library "libpng.so" not found
Can anyone help with that?
I have followed suggestion of Dmitry Zaitsev & thannks to him , solved my problem also .
Please update your TessBaseAPI.java from tess-two library project as below :
static {
System.loadLibrary("png");
System.loadLibrary("lept");
System.loadLibrary("tess");
nativeClassInit();
}
Build tess-two project after updating these file . In my case I have build it using eclipse.
Hope it should solve your problem as well.
It seems like System.loadLibrary("png") call is missing in TessBaseAPI, therefore library can't be found.
Try to call System.loadLibrary("png") before calling new TessBaseAPI(). Typically this is done in static initialization block, like so:
public class MyClass {
static {
System.loadLibrary("png");
}
public void doStuff() {
new TessBaseAPI();
}
}
I have an Android application with Google Maps V2 configured with maven in Eclipse. So I have a "mavenised" Google Play Services lib in the worspace, and the app pom has two maven dependencies to google-play-services jar and apklib.
I implemented a dummy test which only checks if a map fragment is not null:
#RunWith(RobolectricTestRunner.class)
public class MapsTest {
private GoogleMap map;
private ElementMapActivity activity;
#Before
public void setUp() throws Exception {
activity = new ElementMapActivity();
activity.onCreate(null);
}
#Test
public void mapExists() {
// Try to obtain the map from the SupportMapFragment.
map = ((SupportMapFragment) activity.getSupportFragmentManager()
.findFragmentById(R.id.elementMap)).getMap();
Assert.assertNotNull(map);
}
}
Note: a similar code is used in the real application activity to show the map, and it runs OK.
I don't implement any custom testrunners.
I run the test with maven: mvn test.
With Robolectric 1.2 the test builds and executes, but the assertNotNull fails, as the map instance is null. The fragment is not correctly recovered.
With Robolectric 2.1.1 the test builds but fails to execute. I get an exception for each test in the project (not only for the one that tests the maps):
WARNING: no system properties value for ro.build.date.utc
java.lang.RuntimeException: .\..\google-play-services_lib\AndroidManifest.xml not found or not a file; it should point to your project's AndroidManifest.xml
at org.robolectric.AndroidManifest.validate(AndroidManifest.java:108)
at org.robolectric.AndroidManifest.getResourcePath(AndroidManifest.java:274)
at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:280)
at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:282)
at org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:576)
at org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:568)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:89)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:103)
at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
It seems that Robolectric tries to use the google-play-services library manifest instead of the main application manifest, which is in the default location: the app root folder. The library manifest is in it's own root folder as well.
Am I missing some configuration for the tests? Should I use a custom testrunner? Or is it that Google Maps V2 are not supported with Robolectric 2?
Edit: I can do without the maps tests. The problem is that with Robolectric 2 all the other tests get this error too, just by having the google-play-library dependency, so I can not use Robolectric 2 by now. I would like to know if this is a known bug in order to decide to go back to Robolectric 1 or not. I checked Robolectric bug reports and didn't find anything about this.
I have recently encountered the same problem with ActionBarSherlock when running my Robolectric tests under my Maven build plan.
The problem was not evident when I was completing builds on a Windows machine and only became apparent after I switched my laptop for a OSX power device.
I found that the problem was that the library name "google-play-services_lib" doesn't (exactly) match that of the folder name in the directory structure. In my case, my Eclipse project was called "ActionBarSherlock-4.3.1" whereas the folder itself was called "actionbarsherlock" under the file system.
I recommend that you synchronise the two names (Eclipse project and file system) and re-run your tests. Hope that helps.
Testing Android Apps, with Robolectric 2.1.1, that use google-play-services_lib (Google Maps) produces AndroidManifest.xml not found RuntimeException.
The short answer is here in bold. The long answer is below it.
Look in your project for a file named project.properties
Create a new file called test-project.properties
Override any or all of the android.library.reference.$
For example in my project.properties it had this library reference:
**android.library.reference.1=../../../ADK/adt-bundle-windows-x86_64-20130522/sdk/extras/google/google_play_services/libproject/google-play-services_lib**
I overrode it in the test-project.properties file
android.library.reference.1=res
Put the AndroidManifest.xml from the google-play-services_lib into the res(or any folder in the project) folder of the project you are testing
The long answer:
I was having the same issue and was thinking the problem was the same as described above "google-play-services library manifest instead of the main application manifest" So I removed all my references to the google-place-services_lib and still received the error. I downloaded the 2.1.1 Robolectric code from github and started debugging through it. I found that org.robolectric.AndroidManifest class has a method called getLibraryManifests which calls createLibraryManifests and that calls findLibraries. One of the things it does is loads the project.properties file in your project. In my case my project.properties file at this content:
android.library.reference.1=../../../ADK/adt-bundle-windows-x86_64-20130522/sdk/extras/google/google_play_services/libproject/google-play-services_lib
This was created when I used the Android Tools for the google play services install per Google's documentation. If you comment out that line from project.properties file then the error goes away. A better solution is to leave it and then create your own file called test-project.properties and put in the correct directory for android.library.reference.1 and the AndroidManifest will override the original value.
Here is the relevant code from AndroidManifest.java
protected List<FsFile> findLibraries() {
FsFile baseDir = getBaseDir();
List<FsFile> libraryBaseDirs = new ArrayList<FsFile>();
Properties properties = getProperties(baseDir.join("project.properties"));
// get the project.properties overrides and apply them (if any)
Properties overrideProperties = getProperties(baseDir.join("test-project.properties"));
if (overrideProperties!=null) properties.putAll(overrideProperties);
if (properties != null) {
int libRef = 1;
String lib;
while ((lib = properties.getProperty("android.library.reference." + libRef)) != null) {
FsFile libraryBaseDir = baseDir.join(lib);
libraryBaseDirs.add(libraryBaseDir);
libRef++;
}
}
return libraryBaseDirs;
}