Why does Androidx.appcompat.AppCompatActivity throw java.lang.NoSuchMethodError: No virtual method...
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I recently modified my app to use the AndroidX libraries and I'm attempting to use the androidx.biometric.BiometricPrompt in an AppCompatActivity.
However, I get the following exception:
java.lang.NoSuchMethodError: No virtual method getMainExecutor()Ljava/util/concurrent/Executor
I've tried to use the application context instead but that didn't work either.
import androidx.biometric.BiometricPrompt;
import androidx.appcompat.app.AppCompatActivity;
class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
final BiometricPrompt.PromptInfo info = new BiometricPrompt.PromptInfo.Builder()
.setTitle("Login")
.setSubtitle("Perform login with your fingerprint")
.setNegativeButtonText("Cancel")
.build();
new BiometricPrompt(this, getMainExecutor(), onFingerprintAuthentication())
.authenticate(info, getCryptoObject());
}
}
These are the AndroidX libraries I'm importing
implementation 'androidx.core:core:1.1.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.mediarouter:mediarouter:1.1.0-alpha01'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.biometric:biometric:1.0.0-alpha03'
java android androidx
add a comment |
I recently modified my app to use the AndroidX libraries and I'm attempting to use the androidx.biometric.BiometricPrompt in an AppCompatActivity.
However, I get the following exception:
java.lang.NoSuchMethodError: No virtual method getMainExecutor()Ljava/util/concurrent/Executor
I've tried to use the application context instead but that didn't work either.
import androidx.biometric.BiometricPrompt;
import androidx.appcompat.app.AppCompatActivity;
class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
final BiometricPrompt.PromptInfo info = new BiometricPrompt.PromptInfo.Builder()
.setTitle("Login")
.setSubtitle("Perform login with your fingerprint")
.setNegativeButtonText("Cancel")
.build();
new BiometricPrompt(this, getMainExecutor(), onFingerprintAuthentication())
.authenticate(info, getCryptoObject());
}
}
These are the AndroidX libraries I'm importing
implementation 'androidx.core:core:1.1.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.mediarouter:mediarouter:1.1.0-alpha01'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.biometric:biometric:1.0.0-alpha03'
java android androidx
1
getMainExecutor
was added toContext
in API level 28. However,ContextCompat
(androidx.core.content.ContextCompat
) has a staticgetMainExecutor
method that you should be able to use.
– Michael
Jan 4 at 9:19
@Michael Thank you so much! That fixed my problem.
– Christopher Araujo
Jan 4 at 10:17
add a comment |
I recently modified my app to use the AndroidX libraries and I'm attempting to use the androidx.biometric.BiometricPrompt in an AppCompatActivity.
However, I get the following exception:
java.lang.NoSuchMethodError: No virtual method getMainExecutor()Ljava/util/concurrent/Executor
I've tried to use the application context instead but that didn't work either.
import androidx.biometric.BiometricPrompt;
import androidx.appcompat.app.AppCompatActivity;
class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
final BiometricPrompt.PromptInfo info = new BiometricPrompt.PromptInfo.Builder()
.setTitle("Login")
.setSubtitle("Perform login with your fingerprint")
.setNegativeButtonText("Cancel")
.build();
new BiometricPrompt(this, getMainExecutor(), onFingerprintAuthentication())
.authenticate(info, getCryptoObject());
}
}
These are the AndroidX libraries I'm importing
implementation 'androidx.core:core:1.1.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.mediarouter:mediarouter:1.1.0-alpha01'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.biometric:biometric:1.0.0-alpha03'
java android androidx
I recently modified my app to use the AndroidX libraries and I'm attempting to use the androidx.biometric.BiometricPrompt in an AppCompatActivity.
However, I get the following exception:
java.lang.NoSuchMethodError: No virtual method getMainExecutor()Ljava/util/concurrent/Executor
I've tried to use the application context instead but that didn't work either.
import androidx.biometric.BiometricPrompt;
import androidx.appcompat.app.AppCompatActivity;
class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
final BiometricPrompt.PromptInfo info = new BiometricPrompt.PromptInfo.Builder()
.setTitle("Login")
.setSubtitle("Perform login with your fingerprint")
.setNegativeButtonText("Cancel")
.build();
new BiometricPrompt(this, getMainExecutor(), onFingerprintAuthentication())
.authenticate(info, getCryptoObject());
}
}
These are the AndroidX libraries I'm importing
implementation 'androidx.core:core:1.1.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.mediarouter:mediarouter:1.1.0-alpha01'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.biometric:biometric:1.0.0-alpha03'
java android androidx
java android androidx
edited Jan 4 at 8:57
Christopher Araujo
asked Jan 4 at 8:52
Christopher AraujoChristopher Araujo
1086
1086
1
getMainExecutor
was added toContext
in API level 28. However,ContextCompat
(androidx.core.content.ContextCompat
) has a staticgetMainExecutor
method that you should be able to use.
– Michael
Jan 4 at 9:19
@Michael Thank you so much! That fixed my problem.
– Christopher Araujo
Jan 4 at 10:17
add a comment |
1
getMainExecutor
was added toContext
in API level 28. However,ContextCompat
(androidx.core.content.ContextCompat
) has a staticgetMainExecutor
method that you should be able to use.
– Michael
Jan 4 at 9:19
@Michael Thank you so much! That fixed my problem.
– Christopher Araujo
Jan 4 at 10:17
1
1
getMainExecutor
was added to Context
in API level 28. However, ContextCompat
(androidx.core.content.ContextCompat
) has a static getMainExecutor
method that you should be able to use.– Michael
Jan 4 at 9:19
getMainExecutor
was added to Context
in API level 28. However, ContextCompat
(androidx.core.content.ContextCompat
) has a static getMainExecutor
method that you should be able to use.– Michael
Jan 4 at 9:19
@Michael Thank you so much! That fixed my problem.
– Christopher Araujo
Jan 4 at 10:17
@Michael Thank you so much! That fixed my problem.
– Christopher Araujo
Jan 4 at 10:17
add a comment |
1 Answer
1
active
oldest
votes
As @Michael mentioned in the comments, one can use
ContextCompat.getMainExecutor(this);
This solved my problem.
Alternatively, as mentioned in this answer, one can also create their own Executor
public class MainThreadExecutor implements Executor {
private final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void execute(@Nonnull Runnable runnable) {
handler.post(runnable);
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54035679%2fwhy-does-androidx-appcompat-appcompatactivity-throw-java-lang-nosuchmethoderror%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As @Michael mentioned in the comments, one can use
ContextCompat.getMainExecutor(this);
This solved my problem.
Alternatively, as mentioned in this answer, one can also create their own Executor
public class MainThreadExecutor implements Executor {
private final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void execute(@Nonnull Runnable runnable) {
handler.post(runnable);
}
}
add a comment |
As @Michael mentioned in the comments, one can use
ContextCompat.getMainExecutor(this);
This solved my problem.
Alternatively, as mentioned in this answer, one can also create their own Executor
public class MainThreadExecutor implements Executor {
private final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void execute(@Nonnull Runnable runnable) {
handler.post(runnable);
}
}
add a comment |
As @Michael mentioned in the comments, one can use
ContextCompat.getMainExecutor(this);
This solved my problem.
Alternatively, as mentioned in this answer, one can also create their own Executor
public class MainThreadExecutor implements Executor {
private final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void execute(@Nonnull Runnable runnable) {
handler.post(runnable);
}
}
As @Michael mentioned in the comments, one can use
ContextCompat.getMainExecutor(this);
This solved my problem.
Alternatively, as mentioned in this answer, one can also create their own Executor
public class MainThreadExecutor implements Executor {
private final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void execute(@Nonnull Runnable runnable) {
handler.post(runnable);
}
}
answered Jan 4 at 10:27
Christopher AraujoChristopher Araujo
1086
1086
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54035679%2fwhy-does-androidx-appcompat-appcompatactivity-throw-java-lang-nosuchmethoderror%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
getMainExecutor
was added toContext
in API level 28. However,ContextCompat
(androidx.core.content.ContextCompat
) has a staticgetMainExecutor
method that you should be able to use.– Michael
Jan 4 at 9:19
@Michael Thank you so much! That fixed my problem.
– Christopher Araujo
Jan 4 at 10:17