[Q]How fix data conection in Defy ICS port?? - Defy Q&A, Help & Troubleshooting

Hi friends i try to port Miui V4 ICS NS to Defy and translate to spannish
Port cm9 08/03/12 quarx to ns 2.3.30...
Apn no have errors and no have 3g conecction
This is a error:
03-31 16:33:40.137: A/NetworkStats(2259): problem reading network stats
03-31 16:33:40.137: A/NetworkStats(2259): java.lang.IllegalStateException: problem parsing idx 1
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.internal.net.NetworkStatsFactory.readNetworkStatsDetail(NetworkStatsFactory.java:300)
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.server.NetworkManagementService.getNetworkStatsUidDetail(NetworkManagementService.java:1282)
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.server.net.NetworkStatsService.performPollLocked(NetworkStatsService.java:831)
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.server.net.NetworkStatsService.updateIfacesLocked(NetworkStatsService.java:743)
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.server.net.NetworkStatsService.updateIfaces(NetworkStatsService.java:721)
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.server.net.NetworkStatsService.access$000(NetworkStatsService.java:128)
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.server.net.NetworkStatsService$1.onReceive(NetworkStatsService.java:612)
03-31 16:33:40.137: A/NetworkStats(2259): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:728)
03-31 16:33:40.137: A/NetworkStats(2259): at android.os.Handler.handleCallback(Handler.java:605)
03-31 16:33:40.137: A/NetworkStats(2259): at android.os.Handler.dispatchMessage(Handler.java:92)
03-31 16:33:40.137: A/NetworkStats(2259): at android.os.Looper.loop(Looper.java:137)
03-31 16:33:40.137: A/NetworkStats(2259): at android.os.HandlerThread.run(HandlerThread.java:60)
03-31 16:33:40.137: A/NetworkStats(2259): Caused by: java.io.FileNotFoundException: /proc/net/xt_qtaguid/stats: open failed: ENOENT (No such file or directory)
03-31 16:33:40.137: A/NetworkStats(2259): at libcore.io.IoBridge.open(IoBridge.java:406)
03-31 16:33:40.137: A/NetworkStats(2259): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-31 16:33:40.137: A/NetworkStats(2259): at com.android.internal.net.NetworkStatsFactory.readNetworkStatsDetail(NetworkStatsFactory.java:269)
Click to expand...
Click to collapse
Help me please

Related

[Q] Why Edited HTC_IME.apk Force Close

Hi,
I'm trying to edit the HTC_IME.apk that came from tha "Deodexed" package to change the FR Azerty keyboard to a QWERTY one.
I extract the APK with apktool: "apktool d HTC_IME.apk c:\HTC_IME\"
I then replace the content of the 2 (portrait and landscape) XML file of the keyboard layout to have what I want.
I repack the APK with apktool: "apktool b c:\HTC_IME\ c:\HTC_IME.apk"
I then re-sign the new package with the autosign.bat utility.
I push it in /system/app to replace the original one that came with the "RodriguezStyle_MoDaCoMoDrOm_V2-3_FIX_Vivid_Sense_A2SD" rom and reboot the phone.
It's all seem ok but as soon as I start the keyboard I get a force close.
I've also try to modify the htc_ime_lo mod by jonasl but it does the same thing. I can install it but as soon as it try to start, force close
Does I have missed something about editing XML file of an APK ? It's the first time I try.
EDIT:
I know it's possible, they do it in the apktool demo!! youtube.com/watch?v=1Aa9zsh6F7A
Thanks !
mr_sarge said:
Hi,
I'm trying to edit the HTC_IME.apk that came from tha "Deodexed" package to change the FR Azerty keyboard to a QWERTY one.
I extract the APK with apktool: "apktool d HTC_IME.apk c:\HTC_IME\"
I then replace the content of the 2 (portrait and landscape) XML file of the keyboard layout to have what I want.
I repack the APK with apktool: "apktool b c:\HTC_IME\ c:\HTC_IME.apk"
I then re-sign the new package with the autosign.bat utility.
I push it in /system/app to replace the original one that came with the "RodriguezStyle_MoDaCoMoDrOm_V2-3_FIX_Vivid_Sense_A2SD" rom and reboot the phone.
It's all seem ok but as soon as I start the keyboard I get a force close.
I've also try to modify the htc_ime_lo mod by jonasl but it does the same thing. I can install it but as soon as it try to start, force close
Does I have missed something about editing XML file of an APK ? It's the first time I try.
Thanks !
Click to expand...
Click to collapse
I'm using it in the hd2 and I installed HTC_ime.apk and clicker.apk
Sent from my HTC HD2 using Tapatalk
Forgot to tell that I have a HTC Legend from Virgin that came with a QWERTY French HTC_IME.
But can't get it with any custom rom since "French (Canada)" is not a choice in the language option. I've downloaded "morelocale 2" to set Fr_CF but it don't give the QWERTY French keyboard.
If I put an umnodified HTC_IME.apk in /system/app or try to instal unmodified HTC_IME_lo.apk (Jonasl mod) it work.
If I try to rebuild one, changing "land_qwery_fr.xm"l and "qwerty_fr.xml" in "/res/xml/" so that when my HTC is in French, my keyboard appear in QWERTY produce the error each time I try.
Just tested it in the Android Emulator. The keyboard still fail with "The application HTC_IME mod (process jonasl.ime) has stopped unexpectedly. Please try again"
Same thing with the original HTC_IME.apk with edited qwerty_fr.xml file.
I don't know what is wrong...
Me again,
Juste tested decompile-recompile-signing without doing anything to the file and the keyboard crash in US and in French.
Why I'm not able to reocompile this APK !
few steps
Did you try to look at the difference of sizes of the .apk package? sometimes a device wants uncompressed apk, when apktool always compress it.
Try to just pull the .apk resign it and push it back, if it crashes it may mean that the rom rejects its signature and you should resign all /system/app and /system/framework directories with the same key.
And you always can look at logcat to identify the problem( by reading the stack trace) which can tell you where there is a problem inside the flow of the program- just in case you edited something you shouldnt
I've just resign HTC_IME_lo.apk without decompile and recompiling it and the apk work.
I will put the log here because I'm not sure what to check !
Ho, and when I compile the apk back, I got some error:
Code:
>apktool b HTC_IME\
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
aapt: warning: string 'kb_tutorial_fuzzy_body' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'kb_tutorial_fuzzy_title' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'kb_tutorial_longpress_body' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'kb_tutorial_longpress_title' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'kb_tutorial_main_desc' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'kb_tutorial_main_title' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'keyboard_ime_settings_fqwerty_space_title' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'main_menu_title' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
aapt: warning: string 'vibration_feedback' has no default translation in C:\Users\SaRgE\Desktop\apktool1.3.2\HTC_IME\res; found: no
I: Copying libs...
I: Building apk file...
C:\Users\SaRgE\Desktop\apktool1.3.2>
Here's the log. I didn't touch anything. Only decompile-recompile-sign:
Code:
I/ActivityManager( 67): Start proc jonasl.ime for service jonasl.ime/.HTCIMEService: pid=613 uid=10028 gids={1015}
W/InputManagerService( 67): Window already focused, ignoring focus gain of: [email protected]
D/dalvikvm( 613): Trying to load lib /data/data/jonasl.ime/lib/libt99.so 0x43d0c108
D/dalvikvm( 613): Added shared lib /data/data/jonasl.ime/lib/libt99.so 0x43d0c108
I/XT9_C ( 613): File "/data/data/jonasl.ime/udb" does not exist.
I/XT9_C ( 613): [loadDefaultRUDB] RUDB size = 20480 (loaded)
I/XT9_C ( 613): [RegisterXT9MDB] MDB size=64 (loaded)
I/XT9_C ( 613): Load mdbType=0 time=0.001671(sec)
I/XT9_JNI ( 613): [Java_T9_nativeLoad] Native side initialization done.
W/WindowManager( 67): Attempted to add window with non-application token WindowToken{43d320f8 token=null}. Aborting.
I/HTC_IME ( 613): onCreateInputView
D/ ( 613): unable to unlink '/data/data/jonasl.ime/shared_prefs/jonasl.i
me_preferences.xml.bak': No such file or directory (errno=2)
I/XT9_JNI ( 613): [Java_T9_nativeLoad] Native side is already initiated.
I/XT9_JNI ( 613): [Java_T9_nativeLoad] Native side is already initiated.
W/ResourceType( 613): No package identifier when getting name for resource number 0x00000000
E/Keyboard( 613): Parse error:android.content.res.Resources$NotFoundException:String resource ID #0x0
D/AndroidRuntime( 613): Shutting down VM
W/dalvikvm( 613): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime( 613): Uncaught handler: thread main exiting due to uncaught exception
D/dalvikvm( 613): GC freed 3558 objects / 280264 bytes in 138ms
E/AndroidRuntime( 613): java.lang.NullPointerException
E/AndroidRuntime( 613): at com.htc.android.htcime.ezsip.EZSIPView.setKeyboard(EZSIPView.java:114)
E/AndroidRuntime( 613): at com.htc.android.htcime.ezsip.PortQwertySIPView.setKeyboardbyLang(PortQwertySIPView.java:129)
E/AndroidRuntime( 613): at com.htc.android.htcime.ezsip.PortQwertySIPView.init(PortQwertySIPView.java:78)
E/AndroidRuntime( 613): at com.htc.android.htcime.util.CodeIMEFinder.loadAllIME(CodeIMEFinder.java:117)
E/AndroidRuntime( 613): at com.htc.android.htcime.HTCIMEService.execOnceAtBoot(HTCIMEService.java:1771)
E/AndroidRuntime( 613): at com.htc.android.htcime.HTCIMEService.onCreateInputView(HTCIMEService.java:176)
E/AndroidRuntime( 613): at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:950)
E/AndroidRuntime( 613): at android.inputmethodservice.InputMethodService.showWindowInner(InputMethodService.java:1303)
E/AndroidRuntime( 613): at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:1278)
E/AndroidRuntime( 613): at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:388)
E/AndroidRuntime( 613): at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:148)
E/AndroidRuntime( 613): at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:45)
E/AndroidRuntime( 613): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 613): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 613): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 613): at java.lang.reflect.Method.invokeNative(NativeMethod)
E/AndroidRuntime( 613): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 613): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 613): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 613): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 67): Sending signal. PID: 613 SIG: 3
I/dalvikvm( 613): threadid=7: reacting to signal 3
E/dalvikvm( 613): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
I/Process ( 706): Sending signal. PID: 706 SIG: 9
I/ActivityManager( 67): Process jonasl.ime (pid 706) has died.
W/ActivityManager( 67): Service crashed 2 times, stopping: ServiceRecord{43cb4aa8 jonasl.ime/.HTCIMEService}
And here's the log when the apps is working (before I try to decompile/reompile it):
Code:
I/ActivityManager( 67): Start proc jonasl.ime for service jonasl.ime/.HTCIMEService: pid=957 uid=10028 gids={1015}
D/dalvikvm( 957): Trying to load lib /data/data/jonasl.ime/lib/libt99.so 0x43d0c108
D/dalvikvm( 957): Added shared lib /data/data/jonasl.ime/lib/libt99.so 0x43d0c108
I/XT9_C ( 957): File "/data/data/jonasl.ime/udb" does not exist.
I/XT9_C ( 957): [loadDefaultRUDB] RUDB size = 20480 (loaded)
I/XT9_C ( 957): [RegisterXT9MDB] MDB size=64 (loaded)
I/XT9_C ( 957): Load mdbType=0 time=0.001726(sec)
I/XT9_JNI ( 957): [Java_T9_nativeLoad] Native side initialization done.
W/WindowManager( 67): Attempted to add window with non-application token WindowToken{43d320f8 token=null}. Aborting.
I/HTC_IME ( 957): onCreateInputView
D/ ( 957): unable to unlink '/data/data/jonasl.ime/shared_prefs/jonasl.ime_preferences.xml.bak': No such file or directory (errno=2)
I/XT9_JNI ( 957): [Java_T9_nativeLoad] Native side is already initiated.
I/XT9_JNI ( 957): [Java_T9_nativeLoad] Native side is already initiated.
D/dalvikvm( 957): GC freed 3655 objects / 280792 bytes in 147ms
I/HTC_IME_jonasl( 957): Current language not set, defaulting to 0 English
E/ActivityThread( 957): Failed to find provider info for customization_settings
E/ActivityThread( 957): Failed to find provider info for customization_settings
E/ActivityThread( 957): Failed to find provider info for customization_settings
E/ActivityThread( 957): Failed to find provider info for customization_settings
D/dalvikvm( 957): Trying to load lib /system/lib/libsoundpool.so 0x0
D/dalvikvm( 957): Added shared lib /system/lib/libsoundpool.so 0x0
W/Resources( 957): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f090195}
W/Resources( 957): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f090196}
D/dalvikvm( 957): GC freed 4366 objects / 388072 bytes in 41ms
I/XT9_C ( 957): [RegisterXT9MDB] MDB size=22112 (loaded)
I/XT9_C ( 957): Load mdbType=1 time=0.002322(sec)
D/dalvikvm( 957): GC freed 5519 objects / 327536 bytes in 72ms
try to use apktool 1.1
skoperst said:
try to use apktool 1.1
Click to expand...
Click to collapse
1.1 is throwing a lot or erroe like:
Code:
C:\Users\SaRgE\Desktop\apktool1.1.0\HTC_IME\smali\com\htc\android\htcime\R$string.smali[434,49] [smali_file, field, nonvoid_type_descriptor] mismatched input [@3068,14631:14632=':I',<158>,434:49] expecting set null
C:\Users\SaRgE\Desktop\apktool1.1.0\HTC_IME\smali\com\htc\android\htcime\R$string.smali[436,49] [smali_file, field, nonvoid_type_descriptor] mismatched input [@3081,14699:14700=':I',<158>,436:49] expecting set null
C:\Users\SaRgE\Desktop\apktool1.1.0\HTC_IME\smali\com\htc\android\htcime\R$string.smali[438,49] [smali_file, field, nonvoid_type_descriptor] mismatched input [@3094,14767:14768=':I',<158>,438:49] expecting set null
C:\Users\SaRgE\Desktop\apktool1.1.0\HTC_IME\smali\com\htc\android\htcime\R$string.smali[440,49] [smali_file, field, nonvoid_type_descriptor] mismatched input [@3107,14835:14836=':I',<158>,440:49] expecting set null
C:\Users\SaRgE\Desktop\apktool1.1.0\HTC_IME\smali\com\htc\android\htcime\R$string.smali[442,49] [smali_file, field, nonvoid_type_descriptor] mismatched input [@3120,14903:14904=':I',<158>,442:49] expecting set null
C:\Users\SaRgE\Desktop\apktool1.1.0\HTC_IME\smali\com\htc\android\htcime\R$string.smali[444,49] [smali_file, field, nonvoid_type_descriptor] mismatched input [@3133,14971:14972=':I',<158>,444:49] expecting set null
Maybe try apk manager
Already Tried it and it doeas the same thing. I've notified Brutt.All, the apktool creator. He have a bug with the latest version of apktool. see here: http://code.google.com/p/android-apktool/issues/detail?id=100
I will wait for is new version to see if it work.
Thanks
Have you solved the problem. I try to mod HTC_IME and has the same problem - repacked keyboard closes if you try to use it.

[q] App force closes after adding admod SDK

Guys,I am trying to integrate admob SDK in my app from the past 3 hours and have no luck.
I have added the jar libraries ( build path), included in build paths, everything is good there.
main activity :
Code:
// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.ad);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
layout
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="a15XZXXXXX3"
ads:loadAdOnCreate="true" />
everything loaded on the manifest file as well!
LOGCAT :
Code:
07-09 15:33:20.362: D/dalvikvm(12621): GC_CONCURRENT freed 188K, 3% free 8916K/9132K, paused 5ms+8ms, total 46ms
07-09 15:33:20.362: E/AndroidRuntime(12621): FATAL EXCEPTION: main
07-09 15:33:20.362: E/AndroidRuntime(12621): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.PACKAGE/com.PACKAGE.MainActivity}: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Looper.loop(Looper.java:137)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-09 15:33:20.362: E/AndroidRuntime(12621): at dalvik.system.NativeStart.main(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): Caused by: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.PACKAGE.MainActivity.onCreate(MainActivity.java:42)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Activity.performCreate(Activity.java:5104)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-09 15:33:20.362: E/AndroidRuntime(12621): ... 11 more
07-09 15:33:22.877: I/Process(12621): Sending signal. PID: 12621 SIG: 9
chintz24 said:
Guys,I am trying to integrate admob SDK in my app from the past 3 hours and have no luck.
07-09 15:33:20.362: E/AndroidRuntime(12621): Caused by: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.PACKAGE.MainActivity.onCreate(MainActivity.java:42)
Click to expand...
Click to collapse
says there, line 42, your asking "NULL" to do something! No idea what is on line 42, but would assume it's your ad view, so maybe your loading the wrong layout ? or even attempting to findViewById before setContentView() ? Would need more info/code
deanwray said:
says there, line 42, your asking "NULL" to do something! No idea what is on line 42, but would assume it's your ad view, so maybe your loading the wrong layout ? or even attempting to findViewById before setContentView() ? Would need more info/code
Click to expand...
Click to collapse
or even attempting to findViewById before setContentView()
This is what I was doing.
Thanks a lot.
Also does it take time to load ads?
because I dont see anything. Not even blank "ads by google"
chintz24 said:
or even attempting to findViewById before setContentView()
This is what I was doing.
Thanks a lot.
Also does it take time to load ads?
because I dont see anything. Not even blank "ads by google"
Click to expand...
Click to collapse
No idea, not used ads yet
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="aXXXXXXXXXXX"
ads:loadAdOnCreate="true" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:minHeight="1dip" />
</RelativeLayout>
This is my layout.xml
Thanks, its sorted, I didnt have any container for my ads. Done now
chintz24 said:
Guys,I am trying to integrate admob SDK in my app from the past 3 hours and have no luck.
I have added the jar libraries ( build path), included in build paths, everything is good there.
main activity :
Code:
// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.ad);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
layout
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="a15XZXXXXX3"
ads:loadAdOnCreate="true" />
everything loaded on the manifest file as well!
LOGCAT :
Code:
07-09 15:33:20.362: D/dalvikvm(12621): GC_CONCURRENT freed 188K, 3% free 8916K/9132K, paused 5ms+8ms, total 46ms
07-09 15:33:20.362: E/AndroidRuntime(12621): FATAL EXCEPTION: main
07-09 15:33:20.362: E/AndroidRuntime(12621): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.PACKAGE/com.PACKAGE.MainActivity}: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Looper.loop(Looper.java:137)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-09 15:33:20.362: E/AndroidRuntime(12621): at dalvik.system.NativeStart.main(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): Caused by: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.PACKAGE.MainActivity.onCreate(MainActivity.java:42)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Activity.performCreate(Activity.java:5104)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-09 15:33:20.362: E/AndroidRuntime(12621): ... 11 more
07-09 15:33:22.877: I/Process(12621): Sending signal. PID: 12621 SIG: 9
Click to expand...
Click to collapse
Hi,
You are mixing the two solutions for integration of admob banners (XML and code). The coding solution assumes that you have a layout that you want to populate with ads (useful when using different ad networks). In your case you define the admob banner in the XML so you don't need to call it at all in the code, If you think to set a listener (to do something when admob failed to show ads) in this case you can call and set your ad listener (that you implement on the activity) this way:
AdView adView = (AdView)findViewById(R.id.ad);
adView.setAdListener (this);
adView.loadAd(new AdRequest());
Hope this will help

[Q] Failed to load details from database using java and php

I have developed an Android apps which includes a function of writing memo.
After user clicks on the view memo, there is a list of memo name. User can click on the specific memo to display the details in edit form.
I have tested the php code by using the browser, it returns the correct memo details.
But unfortunately, after user clicks on the selected memo, the apps has stopped working.
here is the java code:
Code:
public class EditMemoActivity extends Activity {
EditText editMemoName;
EditText editMemoDetails;
Button btnSaveMemo;
Button btnDeleteMemo;
String pid;
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
static String URL = new ServerURL().getURL();
private static final String url_memo_details = URL+"database/get_memo_details.php";
private static final String url_update_memo = URL+"database/update_memo.php";
private static final String url_delete_memo = URL + "database/delete_memo.php";
private static final String TAG_SUCCESS = "success";
private static final String TAG_MEMO = "memo";
private static final String TAG_PID = "pid";
private static final String TAG_MEMO_NAME = "memo_name";
private static final String TAG_MEMO_DETAILS = "memo_details";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_memo);
btnSaveMemo = (Button) findViewById(R.id.btnSaveMemo);
btnDeleteMemo = (Button) findViewById(R.id.btnDeleteMemo);
Intent i = getIntent();
pid = i.getStringExtra(TAG_PID);
new GetMemoDetails().execute();
btnSaveMemo.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
new SaveMemoDetails().execute();
}
});
btnDeleteMemo.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
new DeleteMemo().execute();
}
});
}
class GetMemoDetails extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EditMemoActivity.this);
pDialog.setMessage("Loading memo details. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... params) {
runOnUiThread(new Runnable() {
public void run() {
int success;
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("pid", pid));
JSONObject json = jsonParser.makeHttpRequest(
url_memo_details, "GET", params);
Log.d("Single Memo Details", json.toString());
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
JSONArray memoObj = json
.getJSONArray(TAG_MEMO); // JSON Array
JSONObject memo = memoObj.getJSONObject(0);
;
editMemoName = (EditText) findViewById(R.id.editTextEditMemoName);
editMemoDetails = (EditText) findViewById(R.id.editTextEditMemoDetails);
editMemoName.setText(memo.getString(TAG_MEMO_NAME));
editMemoDetails.setText(memo.getString(TAG_MEMO_DETAILS));
}else{
// memo with pid not found
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
}
here is the log file:
Code:
03-31 11:05:45.986: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.001: D/AbsListView(27729): unregisterIRListener() is called
03-31 11:05:46.026: D/All Memos:(27729): {"memo":[{"memo_name":"To Buy List","memo_details":"maggi, umbrella","pid":"3"},{"memo_name":"To Do List","memo_details":"visit legoland","pid":"4"},{"memo_name":"2014.03.04","memo_details":"tmr rmb go pc fait","pid":"5"},{"memo_name":"123","memo_details":"sadf","pid":"6"},{"memo_name":"123","memo_details":"sadf","pid":"7"},{"memo_name":"123","memo_details":"sadf","pid":"8"}],"success":1}
03-31 11:05:46.051: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.056: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.056: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.061: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.076: D/AbsListView(27729): unregisterIRListener() is called
03-31 11:05:46.136: D/AbsListView(27729): unregisterIRListener() is called
03-31 11:05:46.146: E/ViewRootImpl(27729): sendUserActionEvent() mView == null
03-31 11:05:46.421: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.421: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.421: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:46.421: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.636: D/ProgressBar(27729): setProgress = 0
03-31 11:05:48.636: D/ProgressBar(27729): setProgress = 0, fromUser = false
03-31 11:05:48.636: D/ProgressBar(27729): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 10000
03-31 11:05:48.681: D/AbsListView(27729): unregisterIRListener() is called
03-31 11:05:48.686: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.721: D/ProgressBar(27729): updateDrawableBounds: left = 0
03-31 11:05:48.721: D/ProgressBar(27729): updateDrawableBounds: top = 0
03-31 11:05:48.721: D/ProgressBar(27729): updateDrawableBounds: right = 96
03-31 11:05:48.721: D/ProgressBar(27729): updateDrawableBounds: bottom = 96
03-31 11:05:48.726: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.726: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.726: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.726: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.731: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.871: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.871: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.881: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.886: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.886: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.886: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.886: D/TextLayoutCache(27729): Enable myanmar Zawgyi converter
03-31 11:05:48.906: D/AndroidRuntime(27729): Shutting down VM
03-31 11:05:48.906: W/dalvikvm(27729): threadid=1: thread exiting with uncaught exception (group=0x41e31700)
03-31 11:05:48.916: E/AndroidRuntime(27729): FATAL EXCEPTION: main
03-31 11:05:48.916: E/AndroidRuntime(27729): android.os.NetworkOnMainThreadException
03-31 11:05:48.916: E/AndroidRuntime(27729): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1144)
03-31 11:05:48.916: E/AndroidRuntime(27729): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
03-31 11:05:48.916: E/AndroidRuntime(27729): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
03-31 11:05:48.916: E/AndroidRuntime(27729): at libcore.io.IoBridge.connect(IoBridge.java:112)
03-31 11:05:48.916: E/AndroidRuntime(27729): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
03-31 11:05:48.916: E/AndroidRuntime(27729): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
03-31 11:05:48.916: E/AndroidRuntime(27729): at java.net.Socket.connect(Socket.java:842)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
03-31 11:05:48.916: E/AndroidRuntime(27729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
03-31 11:05:48.916: E/AndroidRuntime(27729): at com.example.test.JSONParser.makeHttpRequest(JSONParser.java:62)
03-31 11:05:48.916: E/AndroidRuntime(27729): at com.example.test.EditMemoActivity$GetMemoDetails$1.run(EditMemoActivity.java:99)
03-31 11:05:48.916: E/AndroidRuntime(27729): at android.os.Handler.handleCallback(Handler.java:730)
03-31 11:05:48.916: E/AndroidRuntime(27729): at android.os.Handler.dispatchMessage(Handler.java:92)
03-31 11:05:48.916: E/AndroidRuntime(27729): at android.os.Looper.loop(Looper.java:137)
03-31 11:05:48.916: E/AndroidRuntime(27729): at android.app.ActivityThread.main(ActivityThread.java:5493)
03-31 11:05:48.916: E/AndroidRuntime(27729): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 11:05:48.916: E/AndroidRuntime(27729): at java.lang.reflect.Method.invoke(Method.java:525)
03-31 11:05:48.916: E/AndroidRuntime(27729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
03-31 11:05:48.916: E/AndroidRuntime(27729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
03-31 11:05:48.916: E/AndroidRuntime(27729): at dalvik.system.NativeStart.main(Native Method)
03-31 11:07:31.716: I/Process(27729): Sending signal. PID: 27729 SIG: 9
here is the php code:
Code:
<?php
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// check for post data
if (isset($_GET["pid"])) {
$pid = $_GET['pid'];
$result = mysql_query("SELECT *FROM memo WHERE pid = $pid");
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$memo = array();
$memo["pid"] = $result["pid"];
$memo["memo_name"] = $result["memo_name"];
$memo["memo_details"] = $result["memo_details"];
// success
$response["success"] = 1;
// user node
$response["memo"] = array();
array_push($response["memo"], $memo);
// echoing JSON response
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "No memo found";
// echo no users JSON
echo json_encode($response);
}
} else {
$response["success"] = 0;
$response["message"] = "No memo found";
// echo no users JSON
echo json_encode($response);
}
} else {
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
chin90 said:
I have developed an Android apps which includes a function of writing memo.
After user clicks on the view memo, there is a list of memo name. User can click on the specific memo to display the details in edit form.
I have tested the php code by using the browser, it returns the correct memo details.
But unfortunately, after user clicks on the selected memo, the apps has stopped working.
Click to expand...
Click to collapse
Your problem
03-31 11:05:48.916: E/AndroidRuntime(27729): android.os.NetworkOnMainThreadException
google for info. In short, the reason is in the name of the exception Need to do networking on a seperate (to the UI) thread
deanwray said:
Your problem
03-31 11:05:48.916: E/AndroidRuntime(27729): android.os.NetworkOnMainThreadException
google for info. In short, the reason is in the name of the exception Need to do networking on a seperate (to the UI) thread
Click to expand...
Click to collapse
Thanks I have solved the problem

wanam exposed error log

xposed log is eating all the space available.
Code:
java.lang.NoSuchFieldError: com.android.systemui.statusbar.policy.ClockCenter#mExpandedHeader
at de.robv.android.xposed.XposedHelpers.findField(XposedHelpers.java:69)
at de.robv.android.xposed.XposedHelpers.getBooleanField(XposedHelpers.java:628)
at ma.wanam.xposed.XSysUIStatusBarClockPackage$1.afterHookedMethod(Unknown Source)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)
at com.android.systemui.statusbar.policy.Clock.updateClock(Native Method)
at com.android.systemui.statusbar.policy.Clock$2$1.run(Clock.java:362)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
can any body know how to fix this?
bump
toinktoink said:
xposed log is eating all the space available.
Code:
java.lang.NoSuchFieldError: com.android.systemui.statusbar.policy.ClockCenter#mExpandedHeader
at de.robv.android.xposed.XposedHelpers.findField(XposedHelpers.java:69)
at de.robv.android.xposed.XposedHelpers.getBooleanField(XposedHelpers.java:628)
at ma.wanam.xposed.XSysUIStatusBarClockPackage$1.afterHookedMethod(Unknown Source)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)
at com.android.systemui.statusbar.policy.Clock.updateClock(Native Method)
at com.android.systemui.statusbar.policy.Clock$2$1.run(Clock.java:362)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
can any body know how to fix this?
Click to expand...
Click to collapse
Can you upload your SystemUI.apk on my main thread?

How to store geofence in disk

Hey guys,
I'm having a problem figuring out a way to store the geofences that my app creates, in order to load them when I run the app again. The purpose is to show a list of geofences created by the user.
I tried to serialize them using Java's Serialization and I also tried to use Gson to convert them into a Json string. The problem with Gson it's when I try to load them, it gives me an error message saying that Geofence is not a class. (which is true, it's an interface).
logcat:
Code:
09-09 21:37:16.148 18137-18137/? D/dalvikvm﹕ Late-enabling CheckJNI
09-09 21:37:17.515 18137-18137/? I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
09-09 21:37:17.515 18137-18137/? W/dalvikvm﹕ VFY: unable to resolve virtual method 614: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
09-09 21:37:17.515 18137-18137/? D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
09-09 21:37:17.515 18137-18137/? I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
09-09 21:37:17.515 18137-18137/? W/dalvikvm﹕ VFY: unable to resolve virtual method 636: Landroid/content/res/TypedArray;.getType (I)I
09-09 21:37:17.515 18137-18137/? D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
09-09 21:37:18.133 18137-18137/? D/GoogleAPIMsg﹕ Construcao do Client Google
09-09 21:37:18.164 18137-18137/? D/Manager﹕ Loading Geofences...
09-09 21:37:18.203 18137-18137/? D/AndroidRuntime﹕ Shutting down VM
09-09 21:37:18.203 18137-18137/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x419307c0)
09-09 21:37:18.234 18137-18137/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartlocation.wilcocsjrxxlxpto/com.smartlocation.wilcocsjrxxlxpto.HomeScreen}: java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.google.android.gms.location.Geofence. Register an InstanceCreator with Gson for this type may fix this problem.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.access$600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5289)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.google.android.gms.location.Geofence. Register an InstanceCreator with Gson for this type may fix this problem.
at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:210)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:186)
at com.google.gson.Gson.fromJson(Gson.java:810)
at com.google.gson.Gson.fromJson(Gson.java:775)
at com.google.gson.Gson.fromJson(Gson.java:724)
at com.google.gson.Gson.fromJson(Gson.java:696)
at com.smartlocation.wilcocsjrxxlxpto.core.Manager.loadGeofences(Manager.java:203)
at com.smartlocation.wilcocsjrxxlxpto.HomeScreen.load(HomeScreen.java:252)
at com.smartlocation.wilcocsjrxxlxpto.HomeScreen.onCreate(HomeScreen.java:66)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293)
************at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
************at android.app.ActivityThread.access$600(ActivityThread.java:153)
************at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
************at android.os.Handler.dispatchMessage(Handler.java:99)
************at android.os.Looper.loop(Looper.java:137)
************at android.app.ActivityThread.main(ActivityThread.java:5289)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:525)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
************at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:48)
at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:207)
************at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:186)
************at com.google.gson.Gson.fromJson(Gson.java:810)
************at com.google.gson.Gson.fromJson(Gson.java:775)
************at com.google.gson.Gson.fromJson(Gson.java:724)
************at com.google.gson.Gson.fromJson(Gson.java:696)
************at com.smartlocation.wilcocsjrxxlxpto.core.Manager.loadGeofences(Manager.java:203)
************at com.smartlocation.wilcocsjrxxlxpto.HomeScreen.load(HomeScreen.java:252)
************at com.smartlocation.wilcocsjrxxlxpto.HomeScreen.onCreate(HomeScreen.java:66)
************at android.app.Activity.performCreate(Activity.java:5133)
************at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
************at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293)
************at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
************at android.app.ActivityThread.access$600(ActivityThread.java:153)
************at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
************at android.os.Handler.dispatchMessage(Handler.java:99)
************at android.os.Looper.loop(Looper.java:137)
************at android.app.ActivityThread.main(ActivityThread.java:5289)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:525)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
************at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.InstantiationException: can't instantiate class com.google.android.gms.location.Geofence; abstract class or interface
at sun.misc.Unsafe.allocateInstance(Native Method)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:525)
************at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:48)
************at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:207)
************at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:186)
************at com.google.gson.Gson.fromJson(Gson.java:810)
************at com.google.gson.Gson.fromJson(Gson.java:775)
************at com.google.gson.Gson.fromJson(Gson.java:724)
************at com.google.gson.Gson.fromJson(Gson.java:696)
************at com.smartlocation.wilcocsjrxxlxpto.core.Manager.loadGeofences(Manager.java:203)
************at com.smartlocation.wilcocsjrxxlxpto.HomeScreen.load(HomeScreen.java:252)
************at com.smartlocation.wilcocsjrxxlxpto.HomeScreen.onCreate(HomeScreen.java:66)
************at android.app.Activity.performCreate(Activity.java:5133)
************at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
************at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293)
************at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
************at android.app.ActivityThread.access$600(ActivityThread.java:153)
************at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
************at android.os.Handler.dispatchMessage(Handler.java:99)
************at android.os.Looper.loop(Looper.java:137)
************at android.app.ActivityThread.main(ActivityThread.java:5289)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:525)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
************at dalvik.system.NativeStart.main(Native Method)
09-09 21:37:18.648 18137-18137/? I/Process﹕ Sending signal. PID: 18137 SIG: 9
code:
Code:
public class Manager implements ResultCallback<Status>, LocationListener {
// Tag para fazer debug
protected static final String MAN = "Manager";
protected static final String SMS = "eventSMS";
protected static final String RING = "eventRing";
private Context mAppContext;
private GoogleApiClient mGoogleApiClient;
private LocationRequest mLocationRequest;
// Listas de Geofences
private TreeMap<String, Geofence> mGeofences;
private TreeMap<String, Event> mEvents;
private int mCounterActiveGeofences;
private PendingIntent mGeofencePendingIntent;
private Intent updateLocIntent;
/* Save */
private Gson gson;
private SharedPreferences prefs;
public Manager(Context context, GoogleApiClient googleApiClient){
mGeofences = new TreeMap<String, Geofence>();
mEvents = new TreeMap<String, Event>();
mGeofencePendingIntent = null;
mAppContext = context;
mGoogleApiClient = googleApiClient;
mCounterActiveGeofences = 0;
prefs = context.getSharedPreferences(Constants.Geofences, Context.MODE_PRIVATE);
gson = new Gson();
}
...
public void saveGeofences(){
String json;
Geofence geofence;
SharedPreferences.Editor editor = prefs.edit();
Log.d(MAN, "Saving Geofences...");
for (Map.Entry<String, Geofence> entry : mGeofences.entrySet()) {
geofence = mGeofences.get(entry.getKey());
json = gson.toJson(geofence);
editor.putString(geofence.getRequestId(), json);
Log.d(MAN, geofence.getRequestId() + " json: " + json);
}
editor.apply();
}
public void loadGeofences(){
Map<String, ?> keys = prefs.getAll();
Log.d(MAN, "Loading Geofences...");
for (Map.Entry<String, ?> entry : keys.entrySet()) {
String jsonString = prefs.getString(entry.getKey(), null);
Geofence geofence = gson.fromJson(jsonString, Geofence.class);
Log.d(MAN, geofence.getRequestId());
mGeofences.put(geofence.getRequestId(), geofence);
}
}
}
Thank you in advance.
wilcocsjr said:
Hey guys,
I'm having a problem figuring out a way to store the geofences that my app creates, in order to load them when I run the app again. The purpose is to show a list of geofences created by the user.
I tried to serialize them using Java's Serialization and I also tried to use Gson to convert them into a Json string. The problem with Gson it's when I try to load them, it gives me an error message saying that Geofence is not a class. (which is true, it's an interface).
Thank you in advance.
Click to expand...
Click to collapse
Could you show your code and show logcat read sticky thread how to post development questions
Sent from my SM-G530H using XDA Free mobile app
AndroidFire said:
Could you show your code and show logcat read sticky thread how to post development questions
Sent from my SM-G530H using XDA Free mobile app
Click to expand...
Click to collapse
Just edited the original post, sorry about that

Categories

Resources