Conflict with activity tags on android manifest: Facebook and Prime31 plugins in Unity3d - unity3d

I'm trying to get a project to work with both the Facebook Unity plugin and (several) Prime31 plugins. I'm trying to create my own activity that extends the Prime31 activity and also incorporates the workaround for Facebook given here: Conflict with activity tags on android manifest: Facebook and Google Play Games in Unity3d
So far, I've got a class that looks like this:
import android.content.Intent;
import android.os.Bundle;
import com.facebook.Session;
public class DQUnityPlayerActivity extends com.prime31.UnityPlayerProxyActivity
{
#Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
}
I've compiled it with javac, packed it up as a .jar file, and put it in /Assets/Plugins/Android. I modified our AndroidManifest.xml like so:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:theme="#android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="true">
<activity android:name=".DQUnityPlayerActivity" android:screenOrientation="sensorLandscape" android:launchMode="singleTask" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
etc...
Now here's where I'm stuck: at this point, when I try to run it on my test device, the class isn't found. ADB shows me this:
E/AndroidRuntime(16863): FATAL EXCEPTION: main
E/AndroidRuntime(16863): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.dqsoft.ChampHearts/com.dqsoft.ChampHearts.DQUnityPlayerActivity}: java.lang.ClassNotFoundException: com.dqsoft.ChampHearts.DQUnityPlayerActivity in loader dalvik.system.PathClassLoader[/mnt/asec/com.dqsoft.ChampHearts-1/pkg.apk]
E/AndroidRuntime(16863): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
E/AndroidRuntime(16863): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(16863): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(16863): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(16863): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(16863): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(16863): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(16863): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(16863): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(16863): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/AndroidRuntime(16863): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/AndroidRuntime(16863): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(16863): Caused by: java.lang.ClassNotFoundException: com.dqsoft.ChampHearts.DQUnityPlayerActivity in loader dalvik.system.PathClassLoader[/mnt/asec/com.dqsoft.ChampHearts-1/pkg.apk]
E/AndroidRuntime(16863): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime(16863): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime(16863): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime(16863): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(16863): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
E/AndroidRuntime(16863): ... 11 more
Any idea what could be wrong?

You need to put your exported jar file inside Assets/Plugins/Android/ folder and make sure in your DQUnityPlayerActivity class you have this line:
package com.dqsoft.ChampHearts;

Related

Mainactivity.java or Katlin folder file is not present in my flutter project

here is image for my error When I run my flutter project on my phone it popup and immediately closes. I Expect that this is Happened because of missing Maingactivit.java or kottlin if this is the case how I fix it
Here is Error I Face
Suppressed: java.lang.ClassNotFoundException: com.likecse_astu.nethouese.MainActivity
E/AndroidRuntime(14139): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(14139): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(14139): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(14139): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(14139): ... 12 more
E/AndroidRuntime(14139): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Logcat Error code
Suppressed: java.lang.ClassNotFoundException: com.likecse_astu.nethouese.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
You can simply create the class file MainActivity.java with the Java code.
public class MainActivity extends FlutterActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
Or You can run flutter create . or fliutter create -a Java .

Spring-data Mongodb JUnit error

I'm working on a spring MVC project using Spring data with Mongodb.
I just created the entities and did the configuration. Then once testing with JUnit i got an error that i couldn't fix. Can anyone help me with this please .
Here is my spring configuration file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<mongo:mongo host="127.0.0.1" port="27017" />
<mongo:db-factory dbname="AgenceAviationDB" />
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>
These are my maven dependencies:
spring-core 4.2.1.RELEASE
mongo-java-driver 2.12.1
spring-data-mongodb 1.4.2.RELEASE
spring-context 4.2.1.RELEASE
junit 4.7
Here is one of my entities:
package com.pfa.agenceDaviation.entities;
import java.io.Serializable;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
#Document
public class Passager implements Serializable{
#Id
private String id;
private String nomP;
private String adresseP;
private String nTelephoneP;
//setters getters and constructors
This is my test class:
package com.pfa.agenceDaviation;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.data.mongodb.core.MongoOperations;
public class testDAO {
#Before
public void setUp() throws Exception {
}
#Test
public void test() {
try {
ApplicationContext ctx = new GenericXmlApplicationContext("ApplicationContext.xml");
MongoOperations mongoOperation = (MongoOperations)ctx.getBean("mongoTemplate");
assertTrue(true);
}
catch (Exception e) {
assertTrue(e.getMessage(),false);
}
}
}
And this is the error i'm getting :
java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration.<init>(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V
at org.springframework.context.expression.StandardBeanExpressionResolver.<init>(StandardBeanExpressionResolver.java:98)
at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:553)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:455)
at org.springframework.context.support.GenericXmlApplicationContext.<init>(GenericXmlApplicationContext.java:70)
at com.pfa.agenceDaviation.testDAO.test(testDAO.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
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.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Can anyone help me with this please. Thanks a lot !
ran mvn dependency:tree
Pay attention to your spring-data-mongodb dependencies
You will notice that spring-data-mongodb is using spring version - 4.2.1.RELEASE
Here is the proof - http://mvnrepository.com/artifact/org.springframework.data/spring-data-mongodb/1.4.2.RELEASE
So, possible solution - update your spring dependecies to 4.2.1
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
Next step, you need to check is you really need to store spring-core and spring-context.If you really need them - just exclude those dependencies from spring-data-mongodb

Is the error: "make: *** No rule to make target `SpecProj_scd.mk'. Stop." causing my app to crash?

My 1st clean & build gives this error:
make: *** No rule to make target `SpecProj_scd.mk'. Stop.
Building a second time, the error is removed. Note that ndk-build, builds fine.
So I run the project on my actual device, a Tablet, and the app crashes.
LogCat:
01-29 16:48:48.081: E/Trace(3766): error opening trace file: No such file or directory (2)
01-29 16:48:48.081: D/jdwp(3766): sendBufferedRequest : len=0x39
01-29 16:48:48.110: D/dalvikvm(3766): open_cached_dex_file : /data/app/com.dece.specproj-2.apk /data/dalvik-cache/data#app#com.dece.specproj-2.apk#classes.dex
01-29 16:48:48.117: D/ActivityThread(3766): BIND_APPLICATION handled : 0 / AppBindData{appInfo=ApplicationInfo{42436e88 com.dece.specproj}}
01-29 16:48:48.128: W/dalvikvm(3766): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/dece/specproj/MainActivity;
01-29 16:48:48.128: W/dalvikvm(3766): Class init failed in newInstance call (Lcom/dece/specproj/MainActivity;)
01-29 16:48:48.128: D/AndroidRuntime(3766): Shutting down VM
01-29 16:48:48.128: W/dalvikvm(3766): threadid=1: thread exiting with uncaught exception (group=0x41e17908)
01-29 16:48:48.137: E/AndroidRuntime(3766): FATAL EXCEPTION: main
01-29 16:48:48.137: E/AndroidRuntime(3766): java.lang.ExceptionInInitializerError
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.Class.newInstanceImpl(Native Method)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.Class.newInstance(Class.java:1319)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.access$600(ActivityThread.java:149)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.os.Looper.loop(Looper.java:153)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.main(ActivityThread.java:4987)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.reflect.Method.invoke(Method.java:511)
01-29 16:48:48.137: E/AndroidRuntime(3766): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
01-29 16:48:48.137: E/AndroidRuntime(3766): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
01-29 16:48:48.137: E/AndroidRuntime(3766): at dalvik.system.NativeStart.main(Native Method)
01-29 16:48:48.137: E/AndroidRuntime(3766): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load hellojni: findLibrary returned null
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.Runtime.loadLibrary(Runtime.java:365)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.System.loadLibrary(System.java:535)
01-29 16:48:48.137: E/AndroidRuntime(3766): at com.dece.specproj.MainActivity.<clinit>(MainActivity.java:13)
01-29 16:48:48.137: E/AndroidRuntime(3766): ... 15 more
So I made sure and that all my directories were correctly added to the Environment Variables PATH, as well as the PATH in Eclipse, i.e. my MinGW bin, MinGW msys bin, cygwin bin, android-ndk, as well as android-sdk...and I think they are all added correctly, so the error still comes up.
I'm not sure what is causing these issues as I am new to Android NDK, so I will post what I think may play a part in this.
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SpecProj
LOCAL_SRC_FILES := hellojni.c
include $(BUILD_SHARED_LIBRARY)
hellojni.c
#include <string.h>
#include <jni.h>
jstring Java_com_dece_MainActivity_stringFromJNI(JNIEnv* env,jobject thiz)
{
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
MainActivity
package com.dece.specproj;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
public native String stringFromJNI();
static
{
System.loadLibrary("hellojni");
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
activity_main
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.dece.specproj.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dece.specproj"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The core of the problem is this:
01-29 16:48:48.137: E/AndroidRuntime(3766): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load hellojni: findLibrary returned null
It is unable to find a library called libhellojni.so (which you try to load in your java file with System.loadLibrary("hellojni");. Your shared library name is set in Android.mk in this line: LOCAL_MODULE := SpecProj (resulting in a file named libSpecProj.so).
To make things work, change the line in the java file to System.loadLibrary("SpecProj");.
I don't see where the error quoted in the question title would be coming from, but it is at least not directly linked to the error you're seeing at runtime. It may indicate that something else is weirdly set up in your project build (but nothing of what you quoted in the code snippets indicate that, so it would be things outside of that).

Google Maps API V2 android app on API level 8 up to 17

I am working with the Google maps API V2 and it is going fine. i have a 2.2.2 android device wich i use to debug my app.
now i just got a Galaxy Note 2, and when i try to debug on that device the app imidiatly crashed "project has stopped working".
So i just made a small example to test with. and again it runs great on 2.2.2 but not on 4.1.1.
this is the code i have for the small example exercise
Any suggestions would be much appreciated
My Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:id="#+id/tv_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tv_location"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
My Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ss"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.ss.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.ss.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.ss.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my key"/>
</application>
</manifest>
and my testing code
public class MainActivity extends FragmentActivity implements LocationListener{
private GoogleMap googleMap;
private LatLng source;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
if(status!=ConnectionResult.SUCCESS){
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}else{
SupportMapFragment fm = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
googleMap = fm.getMap();
googleMap.setMyLocationEnabled(false);
LocationManager locManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locManager.getBestProvider(criteria, true);
Location loc = locManager.getLastKnownLocation(provider);
if(loc!=null){
onLocationChanged(loc);
}
source = new LatLng(loc.getLatitude(), loc.getLongitude());
//makeUrl = new MakeUrl(source, destination);
//String url = makeUrl.makeLocationUrl();
googleMap.moveCamera(CameraUpdateFactory.newLatLng(source));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
#Override
public void onLocationChanged(Location arg0) {
// TODO Auto-generated method stub
}
#Override
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
}
#Override
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
}
#Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
// TODO Auto-generated method stub
}
}
The stacktrace that i get on my NOTE 2
02-17 13:03:23.135: D/dalvikvm(9527): Late-enabling CheckJNI
02-17 13:03:23.170: E/Trace(9527): error opening trace file: No such file or directory (2)
02-17 13:03:23.345: D/dalvikvm(9527): GC_CONCURRENT freed 179K, 6% free 12453K/13191K, paused 2ms+1ms, total 33ms
02-17 13:03:23.345: D/dalvikvm(9527): WAIT_FOR_CONCURRENT_GC blocked 26ms
02-17 13:03:23.575: D/dalvikvm(9527): GC_CONCURRENT freed 279K, 7% free 12634K/13511K, paused 12ms+1ms, total 24ms
02-17 13:03:23.665: D/dalvikvm(9527): GC_CONCURRENT freed 276K, 7% free 12862K/13703K, paused 2ms+12ms, total 29ms
02-17 13:03:23.705: D/AbsListView(9527): Get MotionRecognitionManager
02-17 13:03:23.740: D/dalvikvm(9527): GC_CONCURRENT freed 194K, 6% free 13206K/13959K, paused 2ms+2ms, total 20ms
02-17 13:03:23.740: D/dalvikvm(9527): WAIT_FOR_CONCURRENT_GC blocked 9ms
02-17 13:03:23.745: D/dalvikvm(9527): WAIT_FOR_CONCURRENT_GC blocked 9ms
02-17 13:03:23.760: D/AndroidRuntime(9527): Shutting down VM
02-17 13:03:23.760: W/dalvikvm(9527): threadid=1: thread exiting with uncaught exception (group=0x41c802a0)
02-17 13:03:23.760: E/AndroidRuntime(9527): FATAL EXCEPTION: main
02-17 13:03:23.760: E/AndroidRuntime(9527): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mm/com.example.mm.MainActivity}: java.lang.NullPointerException
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.ActivityThread.access$600(ActivityThread.java:140)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.os.Looper.loop(Looper.java:137)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.ActivityThread.main(ActivityThread.java:4898)
02-17 13:03:23.760: E/AndroidRuntime(9527): at java.lang.reflect.Method.invokeNative(Native Method)
02-17 13:03:23.760: E/AndroidRuntime(9527): at java.lang.reflect.Method.invoke(Method.java:511)
02-17 13:03:23.760: E/AndroidRuntime(9527): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
02-17 13:03:23.760: E/AndroidRuntime(9527): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
02-17 13:03:23.760: E/AndroidRuntime(9527): at dalvik.system.NativeStart.main(Native Method)
02-17 13:03:23.760: E/AndroidRuntime(9527): Caused by: java.lang.NullPointerException
02-17 13:03:23.760: E/AndroidRuntime(9527): at com.example.mm.MainActivity.onCreate(MainActivity.java:82)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.Activity.performCreate(Activity.java:5191)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
02-17 13:03:23.760: E/AndroidRuntime(9527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
02-17 13:03:23.760: E/AndroidRuntime(9527): ... 11 more
02-17 13:03:23.955: D/dalvikvm(9527): GC_CONCURRENT freed 233K, 6% free 13394K/14215K, paused 14ms+1ms, total 44ms
Seems like there is no last known location for that location provider. This can happen, if that location provider never had a location fix.
Simply try to better work around the case where loc == null.

PackageInfo versionCode and versionName null on phone, but works on emulator

I am building a private app that will not go through the Marketplace. As a result, I need to pull the current version application (not platform) information and check with the server to see if there is an update. It works great on the emulator, but when I installed the signed APK on my Droid X, it returns null. Here is the code:
PackageInfo pInfo = null;
try {
pInfo = getPackageManager().getPackageInfo("com.rubiconproject.expenses",
PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
return;
}
String postUrl = DbAdapter.REMOTE_DB +
"/application/active-version/platform/android/version/" +
pInfo.versionCode + "." + pInfo.versionName;
EDIT:
I wrote a much smaller application, below, that displays my problem (TestingActivity.java):
package com.rubiconproject.testing;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.widget.TextView;
public class TestingActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PackageInfo pInfo = null;
try {
pInfo = getPackageManager().getPackageInfo(
"com.rubiconproject.testing", PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
return;
}
TextView tt = (TextView)findViewById(R.id.textView1);
tt.setText(pInfo.versionCode);
TextView tt2 = (TextView)findViewById(R.id.textView2);
tt2.setText(pInfo.versionName);
}
}
And the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rubiconproject.testing"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".TestingActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
adb logcat shows:
E/AndroidRuntime( 335): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rubiconproject.testing/com.rubiconproject.testing.TestingActivity}: java.lang.NullPointerException
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
E/AndroidRuntime( 335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
E/AndroidRuntime( 335): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
E/AndroidRuntime( 335): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 335): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 335): at android.app.ActivityThread.main(ActivityThread.java:3647)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 335): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 335): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 335): at com.rubiconproject.testing.TestingActivity.onCreate(TestingActivity.java:26)
E/AndroidRuntime( 335): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
E/AndroidRuntime( 335): ... 11 more
where line 26 corresponds to:
tt.setText(pInfo.versionCode);
Does anyone know why this is happening?
Does your manifest.xml contain android:versionCode and androd:versionName attributes?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package.name"
android:versionCode="2"
android:versionName="1.1">
<application android:icon="#drawable/icon" android:label="#string/app_name">
...
</application>
</manifest>
Figured it out. The problem was between the keyboard and the chair. I was seeing null, when it fact the string was being built improperly.