I’m working on an Android app that uses the Google Drive SDK. I’ve followed an example I found online, but I’m running into a problem when I launch the app. It crashes immediately with a VerifyError.
Here’s a snippet of my main activity:
public class DriveIntegrationActivity extends Activity {
private static final int SELECT_ACCOUNT = 1;
private static String userAccount;
private static int AUTH_REQUEST = 2;
private Button connectButton;
private Context context = this;
private Activity activity = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
connectButton = findViewById(R.id.connect_button);
connectButton.setOnClickListener(v -> selectAccount());
}
private void selectAccount() {
Intent intent = AccountPicker.newChooseAccountIntent(null, null,
new String[]{"com.google"}, false, null, null, null, null);
startActivityForResult(intent, SELECT_ACCOUNT);
}
// ... other methods for authentication and file listing
}
I’ve included the necessary permissions in my manifest:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
When I run the app, I get this error in LogCat:
FATAL EXCEPTION: main
java.lang.VerifyError: com/myapp/driveintegration/DriveIntegrationActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
// ... more stack trace
What could be causing this VerifyError? Any ideas on how to fix it?