Additional Information (the original question below)
After following #ρяσѕρєяK advice in the comments section, I am getting the same error on another file (SizeNotifierRelativeLayout.java) and the error occurs at line 44, which is super.onLayout(changed, l, t, r, b);. The code for this file and the logcat are as follows:
SizeNotifierRelativeLayout.java
package com.app.name.widgets;
import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import android.widget.RelativeLayout;
import com.app.name.AndroidUtilities;
public class SizeNotifierRelativeLayout extends RelativeLayout {
private Rect rect = new Rect();
public SizeNotifierRelativeLayoutDelegate delegate;
public abstract interface SizeNotifierRelativeLayoutDelegate {
public abstract void onSizeChanged(int keyboardHeight);
}
public SizeNotifierRelativeLayout(Context context) {
super(context);
}
public SizeNotifierRelativeLayout(Context context, android.util.AttributeSet attrs) {
super(context, attrs);
}
public SizeNotifierRelativeLayout(Context context, android.util.AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
#Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (delegate != null) {
View rootView = this.getRootView();
int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
this.getWindowVisibleDisplayFrame(rect);
int keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
delegate.onSizeChanged(keyboardHeight);
}
}
}
logcat
10-15 09:09:57.918 23530-23530/? W/System.err﹕ at com.app.name.widgets.SizeNotifierRelativeLayout.onLayout(SizeNotifierRelativeLayout.java:44)
10-15 09:09:57.927 23530-23530/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at android.widget.AbsListView.obtainView(AbsListView.java:2247)
at android.widget.ListView.makeAndAddView(ListView.java:1849)
at android.widget.ListView.fillDown(ListView.java:678)
at android.widget.ListView.fillFromTop(ListView.java:739)
at android.widget.ListView.layoutChildren(ListView.java:1664)
at android.widget.AbsListView.onLayout(AbsListView.java:2050)
at android.view.View.layout(View.java:14243)
at android.view.ViewGroup.layout(ViewGroup.java:4490)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1021)
at com.app.name.widgets.SizeNotifierRelativeLayout.onLayout(SizeNotifierRelativeLayout.java:44)
at android.view.View.layout(View.java:14243)
at android.view.ViewGroup.layout(ViewGroup.java:4490)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14243)
at android.view.ViewGroup.layout(ViewGroup.java:4490)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1670)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1528)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1441)
at android.view.View.layout(View.java:14243)
at android.view.ViewGroup.layout(ViewGroup.java:4490)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14243)
at android.view.ViewGroup.layout(ViewGroup.java:4490)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1670)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1528)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1441)
at android.view.View.layout(View.java:14243)
at android.view.ViewGroup.layout(ViewGroup.java:4490)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14243)
at android.view.ViewGroup.layout(ViewGroup.java:4490)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2230)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1994)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1181)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4942)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
at android.view.Choreographer.doCallbacks(Choreographer.java:579)
at android.view.Choreographer.doFrame(Choreographer.java:548)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5370)
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:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Orginal Question-> I have a statusbar get height function which is giving me a
FATAL EXCEPTION: main java.lang.ExceptionInInitializerError
The error is set of when MyActivity calls the
AndroidUtilities.statusBarHeight = getStatusBarHeight();
The function corresponding error:
at com.app.name.AndroidUtilities.(AndroidUtilities.java:31)
is
density = App.getInstance().getResources().getDisplayMetrics().density;
As I am relatively new to Android and Java, I would appreciate pointers as to what I am missing. Thanks!
MyActivity.java
package com.app.name;
import com.app.name.widgets.SizeNotifierRelativeLayout;
public class MyActivity extends ActionBarActivity implements ISideNavigationCallback, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate, NotificationCenter.NotificationCenterDelegate {
private SizeNotifierRelativeLayout sizeNotifierRelativeLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
AndroidUtilities.statusBarHeight = getStatusBarHeight();
sizeNotifierRelativeLayout = (SizeNotifierRelativeLayout) findViewById(R.id.chat_layout);
sizeNotifierRelativeLayout.delegate = this;
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
}
/**
* Get the system status bar height
* #return
*/
public int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}
}
App.java
package com.app.name;
import android.app.Application;
import android.os.Handler;
public class App extends Application {
private static App Instance;
public static volatile Handler applicationHandler = null;
#Override
public void onCreate() {
super.onCreate();
Instance=this;
applicationHandler = new Handler(getInstance().getMainLooper());
NativeLoader.initNativeLibs(App.getInstance());
}
public static App getInstance()
{
return Instance;
}
}
AndroidUtilities.java
package com.app.name;
public class AndroidUtilities {
public static float density = 1;
public static int statusBarHeight = 0;
public static Point displaySize = new Point();
static {
density = App.getInstance().getResources().getDisplayMetrics().density;
checkDisplaySize();
}
}
logcat
10-15 07:57:41.119 15076-15076/? W/System.err? at com.app.name.MyActivity.onCreate(MyActivity.java:197)
10-15 07:57:41.130 15076-15076/? W/System.err? at com.app.name.AndroidUtilities.<clinit>(AndroidUtilities.java:31)
10-15 07:57:41.145 15076-15076/? E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.app.name.MyActivity.onCreate(MyActivity.java:197)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1150)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
at android.app.ActivityThread.access$600(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5370)
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:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.app.name.AndroidUtilities.<clinit>(AndroidUtilities.java:31)
at com.app.name.MyActivity.onCreate(MyActivity.java:197)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1150)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
at android.app.ActivityThread.access$600(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5370)
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:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Related
I write this counter but when I lunch the app get crashed I don't now where the error some help and thank you tell where is the Error here or how can I do code in right way
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
TextView txt = (TextView)findViewById(R.id.textView);
count i;
public void bu1(View view) {
starrtime();
}
public void bu2(View view) {
i.cancel();
}
void starrtime(){
i = new count(100,1000);
i.start();
}
public class count extends CountDownTimer {
public count(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
#Override
public void onTick(long millisUntilFinished) {
txt.setText(String.valueOf(millisUntilFinished));
}
#Override
public void onFinish() {
txt.setText("Done");
}
}
}
this my log cat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.kira.counter, PID: 4598
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.kira.counter/com.example.kira.counter.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:116)
at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:147)
at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:27)
at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:50)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:190)
at com.example.kira.counter.MainActivity.(MainActivity.java:23)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
I believe you can not initialize a TextView before runtime because the views are not set yet. Classes should be capitalized. Try this.
public class MainActivity extends AppCompatActivity{
private TextView txt;
private Count i;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt = (TextView)findViewById(R.id.textView);
}
}
This event makes me think I forgot everything about programming in Java, as a NPE is thrown without any variable set to null.
In the next code how is it possible that the process reach the catch clause with e equal to NPE if neither msg nor mqttAndroidClient are null?
BTW, MqttAndroidClient is not supposed to throw a NPE according to MQTT documentation.
public class MainActivity extends AppCompatActivity {
MqttAndroidClient mqttAndroidClient;
final String serverUri = "tcp://iot.eclipse.org:1883";
String clientId = "ExampleAndroidClient";
final String publishTopic = "location";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mqttAndroidClient = MqttClientSingleton.getMqttClient(getApplicationContext(), serverUri, clientId);
mqttAndroidClient.setCallback(new MqttCallback() {
#Override
public void connectionLost(Throwable cause) {
try {
mqttAndroidClient.connect();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
#Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
}
#Override
public void deliveryComplete(IMqttDeliveryToken token) {
}
});
mqttAndroidClient.connect();
try {
MqttMessage msg = new MqttMessage("test".getBytes());
mqttAndroidClient.publish(publishTopic, msg);
} catch (Exception e) {
throw new RuntimeException(e);
}
;
}
}
This is the MqttClientSingleton
import android.content.Context;
import org.eclipse.paho.android.service.MqttAndroidClient;
/**
* Created by storassa on 4/30/17.
*/
public class MqttClientSingleton {
private static MqttAndroidClient client;
public static MqttAndroidClient getMqttClient(Context c, String uri, String id) {
if (client == null) {
client = new MqttAndroidClient(c, uri, id);
return client;
}
else
return client;
}
}
This is the logcat
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.storassa.android.giulia/com.storassa.android.giulia.MainActivity}: java.lang.RuntimeException: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:788)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at com.storassa.android.giulia.MainActivity.onCreate(MainActivity.java:54)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2166)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:788)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at org.eclipse.paho.android.service.MqttAndroidClient.publish(MqttAndroidClient.java:812)
at org.eclipse.paho.android.service.MqttAndroidClient.publish(MqttAndroidClient.java:668)
at com.storassa.android.giulia.MainActivity.onCreate(MainActivity.java:52)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2166)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:788)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
NEW EDIT
I added the MqttClientSingleton code and the line with mqttAndroidClient.connect() that got lost in the copy and paste
This is a problem that forked off a different issue.
I'm passing two strings from my main activity to a child service, which is fine, but when the main activity dies, the service throws a NullPointerException trying to grab the two strings.
From MainActivity:
Intent i = new Intent(this, PebbleService.class);
i.putExtra("quote", quote[0]);
i.putExtra("author", quote[1]);
startService(i);
From PebbleService:
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
final String author = intent.getStringExtra("author");
final String quote = intent.getStringExtra("quote");
// Define AppMessage behavior
if (appMessageReciever == null) {
appMessageReciever = new PebbleKit.PebbleDataReceiver(WATCHAPP_UUID) {
#Override
public void receiveData(Context context, int transactionId, PebbleDictionary data) {
// Always ACK
PebbleKit.sendAckToPebble(context, transactionId);
// Send KEY_QUOTE to Pebble
PebbleDictionary out = new PebbleDictionary();
out.addString(KEY_QUOTE, quote);
out.addString(KEY_AUTHOR, author);
PebbleKit.sendDataToPebble(getApplicationContext(), WATCHAPP_UUID, out);
}
};
// Add AppMessage capabilities
PebbleKit.registerReceivedDataHandler(this, appMessageReciever);
}
return START_STICKY;
}
Error from Logcat:
05-26 10:29:52.972 4147-4147/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: net.thevgc.quotes, PID: 4147
java.lang.RuntimeException: Unable to start service net.thevgc.quotes.PebbleService#423eb138 with null: java.lang.NullPointerException
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2732)
at android.app.ActivityThread.access$2100(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at net.thevgc.quotes.PebbleService.onStartCommand(PebbleService.java:34)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2715)
at android.app.ActivityThread.access$2100(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
As per the documentation:
intent - ... This may be null if the service is being restarted
Therefore check for null intent:
public int onStartCommand(Intent intent, int flags, int startId) {
int cmd = super.onStartCommand(intent, flags, startId);
if (intent == null) return cmd;
final String author = intent.getStringExtra("author");
final String quote = intent.getStringExtra("quote");
...
}
I've an error, when using ListView in Android, which is populated with images. Images urls are from tumblr JSON and android query loads them. Error message which I get is:
12-12 21:55:38.032 4334-4334/com.example.tumblrviewer E/InputEventReceiver﹕ Exception dispatching input event.
12-12 21:55:38.040 4334-4334/com.example.tumblrviewer D/dalvikvm﹕ GC_FOR_ALLOC freed 760K, 12% free 9993K/11292K, paused 5ms, total 6ms
12-12 21:55:38.040 4334-4334/com.example.tumblrviewer E/MessageQueue-JNI﹕ java.lang.NullPointerException
at com.example.tumblrviewer.MenuArrayAdapter.getView(MenuArrayAdapter.java:76)
at android.widget.AbsListView.obtainView(AbsListView.java:2161)
at android.widget.ListView.makeAndAddView(ListView.java:1840)
at android.widget.ListView.fillDown(ListView.java:675)
at android.widget.ListView.fillGap(ListView.java:639)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4970)
at android.widget.AbsListView.onGenericMotionEvent(AbsListView.java:3680)
at android.view.View.dispatchGenericMotionEventInternal(View.java:7479)
at android.view.View.dispatchGenericMotionEvent(View.java:7460)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchGenericMotionEvent(PhoneWindow.java:1974)
at com.android.internal.policy.impl.PhoneWindow.superDispatchGenericMotionEvent(PhoneWindow.java:1428)
at android.app.Activity.dispatchGenericMotionEvent(Activity.java:2460)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchGenericMotionEvent(PhoneWindow.java:1928)
at android.view.View.dispatchPointerEvent(View.java:7566)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:132)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
12-12 21:55:38.044 4334-4334/com.example.tumblrviewer D/AndroidRuntime﹕ Shutting down VM
12-12 21:55:38.044 4334-4334/com.example.tumblrviewer W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4bd3648)
12-12 21:55:38.052 4334-4334/com.example.tumblrviewer E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at com.example.tumblrviewer.MenuArrayAdapter.getView(MenuArrayAdapter.java:76)
at android.widget.AbsListView.obtainView(AbsListView.java:2161)
at android.widget.ListView.makeAndAddView(ListView.java:1840)
at android.widget.ListView.fillDown(ListView.java:675)
at android.widget.ListView.fillGap(ListView.java:639)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4970)
at android.widget.AbsListView.onGenericMotionEvent(AbsListView.java:3680)
at android.view.View.dispatchGenericMotionEventInternal(View.java:7479)
at android.view.View.dispatchGenericMotionEvent(View.java:7460)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at android.view.ViewGroup.dispatchTransformedGenericPointerEvent(ViewGroup.java:1819)
at android.view.ViewGroup.dispatchGenericPointerEvent(ViewGroup.java:1772)
at android.view.View.dispatchGenericMotionEvent(View.java:7453)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchGenericMotionEvent(PhoneWindow.java:1974)
at com.android.internal.policy.impl.PhoneWindow.superDispatchGenericMotionEvent(PhoneWindow.java:1428)
at android.app.Activity.dispatchGenericMotionEvent(Activity.java:2460)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchGenericMotionEvent(PhoneWindow.java:1928)
at android.view.View.dispatchPointerEvent(View.java:7566)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:132)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
it points to MenuArrayAdapter line 76, which contains:
mAQ.id(viewHolder.mImageView).image(item.photos[0].photoUrl.uri, false, false, 600, 0, null, Constants.FADE_IN);
and I'm pretty sure this object is not null, because error occurs random, each time with different item in ArrayAdapter. It happens when I scroll ListView fast, up and down. I see that images does not have a time to load. Can it be related with a problem with memory? that there is too much data in the memory and app crashes? If so, what would be a good solution, if I want to stay with infinite scroll - I don't want to add "load more" button in the bottom, as e.g. Instagram does not have such button and it can load lots of images.
full code of this class is as follows:
package com.example.tumblrviewer;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import com.androidquery.AQuery;
import com.androidquery.callback.AjaxCallback;
import com.androidquery.callback.AjaxStatus;
import com.androidquery.util.Constants;
import com.example.tumblrviewer.model.HomeResponse;
import com.example.tumblrviewer.model.Item;
import org.json.JSONException;
import org.json.JSONObject;
public class MenuArrayAdapter extends ArrayAdapter<Item> {
private final LayoutInflater mInflater;
private final int mResourceId;
private AQuery mAQ;
private int postOffset;
public MenuArrayAdapter(Context context, int resource) {
super(context, resource);
mInflater = LayoutInflater.from(context);
mResourceId = resource;
mAQ = new AQuery(context);
postOffset=0;
//loadImages(postOffset);
}
public void setPosts(Item[] posts) {
//clear();
for (Item item : posts) {
add(item);
}
if (isEmpty()) {
notifyDataSetInvalidated();
} else {
notifyDataSetChanged();
}
}
#Override
public View getView(int i, View convertView, ViewGroup viewGroup) {
ViewHolder viewHolder = null;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = mInflater.inflate(mResourceId, viewGroup, false);
viewHolder.mImageView = (ImageView) convertView.findViewById(R.id.tumblr_photo_iv);
//viewHolder.mTagsLayout=(LinearLayout) convertView.findViewById(R.id.tags_layout);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Item item = getItem(i);
//if ( item.photos[0].photoUrl.uri != null) {
mAQ.id(viewHolder.mImageView).image(item.photos[0].photoUrl.uri, false, false, 600, 0, null, Constants.FADE_IN);
//}
return convertView;
}
private class ViewHolder {
ImageView mImageView;
//LinearLayout mTagsLayout;
}
}
There is also main activity
package com.example.tumblrviewer;
import android.app.Activity;
import android.os.Bundle;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.androidquery.AQuery;
import com.androidquery.callback.AjaxCallback;
import com.androidquery.callback.AjaxStatus;
import com.example.tumblrviewer.model.HomeResponse;
import org.json.JSONException;
import org.json.JSONObject;
public class WeHaveTheMunchiesActivity extends Activity {
private AQuery mAQ;
private TextView mResultTextView;
private ListView mListView;
private MenuArrayAdapter mItemArrayAdapter;
private int postOffset;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_viewer);
mListView = (ListView) findViewById(R.id.items_lv);
mAQ = new AQuery(this);
mItemArrayAdapter = new MenuArrayAdapter(this, R.layout.item_on_list);
mListView.setAdapter(mItemArrayAdapter);
postOffset=0;
loadImages(postOffset);
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
#Override
public void onScrollStateChanged(AbsListView absListView, int i) {
}
#Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int lastItem = firstVisibleItem + visibleItemCount;
if(lastItem == totalItemCount ){
if(postOffset <= 10662
&& mListView.getChildAt(mListView.getChildCount() - 1) != null
&& mListView.getLastVisiblePosition() == mListView.getAdapter().getCount() - 1
&& mListView.getChildAt(mListView.getChildCount() - 1).getBottom() <= mListView.getHeight()) {
Toast.makeText(getApplicationContext(), "Bottom!", Toast.LENGTH_LONG).show();
loadImages(postOffset);
System.out.println("postOffset "+postOffset);
}
}
}
});
}
private void loadImages(int offset) {
String url = Constants.TUMBLR_API_BLOG_URL + Constants.TUMBLR_API_BLOG_HOSTNAME +
Constants.TUMBLR_API_CONTENT_TYPE + Constants.TUMBLR_API_KEY_NAME +
Constants.TUMBLR_API_KEY + "&offset=" + Integer.toString(offset);
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();
cb.url(url).type(JSONObject.class).weakHandler(this, "itemsCallback");
mAQ.ajax(cb);
postOffset=postOffset+20;
}
public void itemsCallback(String url, JSONObject json, AjaxStatus status) throws JSONException {
//Toast.makeText(getApplicationContext(), status.getRedirect(), Toast.LENGTH_LONG).show();
//Toast.makeText(getApplicationContext(), status.getCode(), Toast.LENGTH_LONG).show();
//mResultTextView.setText(status.getMessage());
if (json != null) {
HomeResponse homeResponse = HomeResponse.fromJsonObject(json.getJSONObject("response"));
System.out.print(homeResponse.items);
mItemArrayAdapter.setPosts(homeResponse.items);
}
}
}
I migrated a project from Eclipse to Android Studio. In my project, I have added this library.
I have added the library as a dependency in my gradle file. I can import the library from my class.But it shows this
android.view.InflateException: Binary XML file line #8: Error inflating class com.digitalaria.gama.wheel.Wheel
while running the app.
Note - It worked fine while running it from Eclipse.
gradle
apply plugin: 'android'
dependencies {
// compile fileTree(dir: 'libs', include: '*.jar')
compile project(':RemoteIt Protocol')
compile project(':android-support-v7-appcompat')
compile files('libs/gama_wheel_v1.0.jar')
compile files('libs/PayPalAndroidSDK.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<com.digitalaria.gama.wheel.Wheel
android:id="#+id/wheel"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</com.digitalaria.gama.wheel.Wheel>
</LinearLayout>
Class
import com.digitalaria.gama.wheel.Wheel;
import com.digitalaria.gama.wheel.WheelAdapter;
public class Home extends MainActivity implements OnClickListener
{
private RemoteIt application;
private SharedPreferences preferences;
#Override
protected void onCreate(Bundle savedInstanceState)
{
this.application = (RemoteIt) this.getApplication();
this.preferences = this.application.getPreferences();
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(s);
this.checkOnCreate();
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.home, null, false);
mDrawer.addView(contentView, 0);
init();
wheel();
}
private void wheel()
{
wheel.setOnItemClickListener(new WheelAdapter.OnItemClickListener()
{
#Override
public void onItemClick(WheelAdapter<?> parent, View view, int position, long id)
{
switch (position)
{
case 0:
Intent ac = new Intent(Home.this, ConnectionListActivity.class);
startActivity(ac);
break;
case 1:
Intent b = new Intent(Home.this, ControlActivity.class);
startActivity(b);
break;
case 2:
Intent c = new Intent(Home.this, FileExplorerActivity.class);
startActivity(c);
// this.toggleKeyboard();
break;
case 3:
Intent d = new Intent(Home.this, Presentation.class);
startActivity(d);
break;
case 4:
Intent e = new Intent(Home.this, Media.class);
startActivity(e);
break;
case 5:
Intent f = new Intent(Home.this, Shortcuts.class);
startActivity(f);
break;
case 6:
Intent g = new Intent(Home.this, Browser.class);
startActivity(g);
break;
}
}
});
}
private Wheel wheel;
private Resources res;
private int[] icons = {
R.drawable.conn, R.drawable.mouse, R.drawable.file, R.drawable.present, R.drawable.media, R.drawable.shortc, R.drawable.browser
};
private void init()
{
res = getApplicationContext().getResources();
wheel = (Wheel) findViewById(R.id.wheel);
wheel.setItems(getDrawableFromData(icons));
wheel.setWheelDiameter((int) getResources().getDimension(R.dimen.diameter));
}
private Drawable[] getDrawableFromData(int[] data)
{
Drawable[] ret = new Drawable[data.length];
for (int i = 0; i < data.length; i++)
{
ret[i] = res.getDrawable(data[i]);
}
return ret;
}
LogCat
Process: com.RemoteIt.client, PID: 1825
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.RemoteIt.client/com.RemoteIt.client.activity.Home}: android.view.InflateException: Binary XML file line #8: Error inflating class com.digitalaria.gama.wheel.Wheel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.digitalaria.gama.wheel.Wheel
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.RemoteIt.client.activity.Home.onCreate(Home.java:50)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.RemoteIt.client.activity.Home.onCreate(Home.java:50)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3
at android.content.res.TypedArray.getInteger(TypedArray.java:368)
at com.digitalaria.gama.wheel.WheelBehavior.<init>(WheelBehavior.java:117)
at com.digitalaria.gama.wheel.Wheel.<init>(Wheel.java:83)
at com.digitalaria.gama.wheel.Wheel.<init>(Wheel.java:68)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.RemoteIt.client.activity.Home.onCreate(Home.java:50)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Wheel.java
public final class Wheel extends android.widget.FrameLayout {
public static final int CCW = -1;
public static final int CW = 1;
private com.digitalaria.gama.wheel.WheelBehavior _wheelBehavior;
private android.view.ViewStub _backgroundViewDummy;
protected android.view.View _backgroundView;
protected boolean _hasBackgroundImage;
private android.widget.FrameLayout.LayoutParams params;
private int _reservedPositionLeft;
private int _reservedPositionTop;
private boolean isLayout;
private int _storedLeft;
private int _storedTop;
private int _storedRight;
private int _storedBottom;
private int _centerX;
private int _centerY;
public Wheel(android.content.Context context) { /* compiled code */ }
public Wheel(android.content.Context context, android.util.AttributeSet attrs) { /* compiled code */ }
public Wheel(android.content.Context context, android.util.AttributeSet attrs, int defStyle) { /* compiled code */ }
protected void onLayout(boolean changed, int l, int t, int r, int b) { /* compiled code */ }
public void addView(android.view.View child) { /* compiled code */ }
public void addView(android.view.View child, int index) { /* compiled code */ }
public void removeView(android.view.View child) { /* compiled code */ }
public void removeViewAt(int index) { /* compiled code */ }
public float getCenterX() { /* compiled code */ }
public float getCenterY() { /* compiled code */ }
public final void setOnItemClickListener(com.digitalaria.gama.wheel.WheelAdapter.OnItemClickListener listener) { /* compiled code */ }
public final com.digitalaria.gama.wheel.WheelAdapter.OnItemClickListener getOnItemClickListener() { /* compiled code */ }
public final void setOnWheelRotationListener(com.digitalaria.gama.wheel.WheelAdapter.OnWheelRotationListener listener) { /* compiled code */ }
public final com.digitalaria.gama.wheel.WheelAdapter.OnWheelRotationListener getOnWheelRotationListener() { /* compiled code */ }
public void setOnItemSelectionUpdatedListener(com.digitalaria.gama.wheel.WheelAdapter.OnItemSelectionUpdatedListener listener) { /* compiled code */ }
public void setPosition(int left, int top) { /* compiled code */ }
public void setSelectionAngle(int angle) { /* compiled code */ }
public void setItems(android.content.res.TypedArray items) { /* compiled code */ }
public void setItems(android.graphics.drawable.Drawable[] drawables) { /* compiled code */ }
public void setWheelDiameter(int diameter) { /* compiled code */ }
public void setWheelBackground(int inflatedId, int layoutResource) { /* compiled code */ }
public void setRotatedItem(boolean flag) { /* compiled code */ }
public void configureWheelBackground(int initRotationAngle, boolean rotatedItem) { /* compiled code */ }
public void configureWheelBackground(boolean rotatedItem) { /* compiled code */ }
protected boolean hasBackgroundImage() { /* compiled code */ }
public void setTouchArea(int from, int to) { /* compiled code */ }
public int nextItem() { /* compiled code */ }
public int previousItem() { /* compiled code */ }
public boolean isRotationFinished() { /* compiled code */ }
public void flingStartUsingAngle(float angle) { /* compiled code */ }
public void flingStartUsingVelocity(int vx, int vy, boolean scroolToSlot) { /* compiled code */ }
public void flingStartUsingVelocityWithDirection(int vx, int vy, int direction) { /* compiled code */ }
public int getSelectedItem() { /* compiled code */ }
public int getSelectedItem(boolean stopScroll) { /* compiled code */ }
public boolean setSelectedItem(int index) { /* compiled code */ }
public void setItemClickEventAtSelectionPosition(boolean enable) { /* compiled code */ }
public boolean getItemClickEventAtSelectionPosition() { /* compiled code */ }
public void setEnabled(boolean enabled) { /* compiled code */ }
public boolean isLayouted() { /* compiled code */ }
}
The relevant exception :
Caused by: java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3
at android.content.res.TypedArray.getInteger(TypedArray.java:368)
at com.digitalaria.gama.wheel.WheelBehavior.<init>(WheelBehavior.java:117)
WheelBehavior.java, line 117
setWheelDiameter(arr.getInteger(R.styleable.Wheel_wheel_diameter, Configuration.DEFAULT_WHEEL_DIAMETER));
Here are the styleable attributes :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Wheel">
<attr name="wheel_rotation_duration" format="integer"/> <!-- default:400 -->
<attr name="wheel_diameter" format="integer"/> <!-- default:250 -->
<attr name="items" format="integer"/>
<attr name="item_selected_index" format="integer"/>
</declare-styleable>
</resources>
wheel_diameter must be defined somewhere in your project, with something else than a integer inside it. That's why it crashed. But according to your layout, it is not. Try a global search on the string wheel_diameter
I think my answer is a rave, but you can try to set layout_gravity="center" or layout_gravity="center_horizontal" cause I think the creator of the library tries to get this property.
Try to replace this code :
compile files('libs/gama_wheel_v1.0.jar')
compile files('libs/PayPalAndroidSDK.jar')
With this code :
compile fileTree(dir: 'libs', include: '*.jar')
Caused by: java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3
at android.content.res.TypedArray.getInteger(TypedArray.java:368)
at com.digitalaria.gama.wheel.WheelBehavior.<init>(WheelBehavior.java:117)
at com.digitalaria.gama.wheel.Wheel.<init>(Wheel.java:83)
at com.digitalaria.gama.wheel.Wheel.<init>(Wheel.java:68)
I think you need to look into this one. Not sure if Wheel is something you made or downloaded, but it seems to be having a problem in its setup.