由于我将我的应用程序迁移到 androidx,因此当我启动任务组合时,Jenkins 出现错误。这是错误:
Program type already present:
android.support.v4.app.INotificationSideChannel$Stub$Proxy
Run Code Online (Sandbox Code Playgroud)
但是我在 Android Studio 上没有这个错误,我可以毫无问题地构建 apk。
因此,我尝试从 google play 服务中排除 support-v4 模块:
implementation( "com.google.android.gms:play-services-maps:16.0.0"){
exclude module: 'support-v4'
}
implementation ("com.google.android.gms:play-services-location:16.0.0"){
exclude module: 'support-v4'
}
implementation ("com.google.android.gms:play-services-places:16.0.0"){
exclude module: 'support-v4'
}
Run Code Online (Sandbox Code Playgroud)
然后生成apk,但在启动应用程序时出现此错误:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArraySet;
at com.google.android.gms.common.api.internal.c.<init>(Unknown Source:45)
at com.google.android.gms.common.api.internal.c.a(Unknown Source:33)
at com.google.android.gms.common.api.e.<init>(Unknown Source:51)
at com.google.android.gms.common.api.e.<init>(Unknown Source:13)
at com.google.android.gms.location.b.<init>(Unknown Source:8)
at com.google.android.gms.location.f.a(Unknown Source:2)
Run Code Online (Sandbox Code Playgroud)
但是再一次,在 Android Studio 上一切正常,自从迁移到 Androidx 以来,问题只出现在 Jenkins 上。
谢谢你的帮助
我在布局中添加了一个工具栏,现在运行时出现此错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/mainactivity.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #2: Error inflating class android.support.design.widget.AppBarLayout
Run Code Online (Sandbox Code Playgroud)
这是我的活动布局:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/appbar"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的应用栏布局:
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_bar"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
在我的活动onCreate()中:
Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么。有什么建议么?
我正在使用androidx库开发一个新的android应用程序,并且需要在布局中使用cardview。
所以我尝试将cardview库添加到我的项目中,但出现此错误ERROR: Failed to resolve: cardview
我检查的答案失败:com.android.support:cardview-v7:26.0.0机器人,但它并不能帮助我
回答像
google()之前添加jcenter() maven { url "https://maven.google.com" }到repositories build.gradle(项目)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.chavosh.porterageapp"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
testImplementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' …Run Code Online (Sandbox Code Playgroud) 我有一个 flutter 应用程序工作正常,然后我想我应该将所有插件升级到 androidX,并且在我决定添加 firebase_messaging 之前一切都工作正常,我尝试过版本 4,5,没有工作,继续抛出该错误,好像我版本错误。我也尝试过,但flutter packages pub cache repair没有运气。github 上有很多相关的问题,但是它们都已关闭,人们仍然抱怨修复不起作用。这是我的 gradle 看起来像
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '3'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) …Run Code Online (Sandbox Code Playgroud)升级到 AndroidX 后,当我设置 LayoutManager 时,我收到此错误“必须是以下之一:RecyclerView.HORIZONTAL、RecyclerView.VERTICAL ”
tournamentRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
问题 ID:错误常量。
检查信息:确保当方法中的参数仅允许一组特定的常量时,调用遵守这些规则
我正在尝试为 android 应用编写测试。其中有 1Activity和 2 fragments(即FragmentOne和FragmentTwo)通过单击FragmentOne它上的按钮转到FragmentTwo. 我写了同样的测试,我正在使用androidxand navigation architecture。我已阅读此链接和此链接,但没有成功。
这是我当前的代码-
示例仪器测试
@RunWith(JUnit4::class)
class ExampleInstrumentedTest {
@Test
fun checkSecondFrag() {
// Create a mock NavController
val mockNavController = mock(NavController::class.java)
// Create a graphical FragmentScenario for the OneFragment
val oneFragmentScenario = launchFragmentInContainer<OneFragment>()
// Set the NavController property on the fragment
oneFragmentScenario.onFragment { fragment ->
Navigation.setViewNavController(fragment.requireView(), mockNavController)
}
// Verify that performing a click prompts …Run Code Online (Sandbox Code Playgroud) android android-espresso android-architecture-components androidx
In my android project in xml I try to use com.google.android.material.textfield.TextInputEditText
like this:
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextEmail"
style="@style/textTextViewStyle"
android:layout_width="0dp"
android:layout_height="@dimen/min_height"
android:layout_margin="@dimen/default_margin"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:padding="@dimen/half_default_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewAppName" />
Run Code Online (Sandbox Code Playgroud)
in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
In app/build.gradle:
android {
dataBinding {
enabled = true
}
compileSdkVersion 29
defaultConfig {
applicationId "com.myapp"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Run Code Online (Sandbox Code Playgroud)
but I get …
android material-design android-support-design material-components-android androidx
我有时希望 onBackPressedDispatcher 吸收后退按钮的按下,但我看不到它的选项。发生的事情是我们今天刚刚尝试升级到 androidX 中的 onBackPressedDispatcher,但我们已经在活动中覆盖了 onBackPress。所以当我们的 onBackPressedDispatcher 之后调用 OnBackPressedCallback 时,也会调用 onBackPressed 覆盖活动。我们不想要那个。onBackpressed 应该当场食用。这是我到目前为止所拥有的:
const val TAG = "MyTag"
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_first)
MyTester(this)
}
override fun onBackPressed() {
super.onBackPressed()
Log.v(TAG, "Activities class back button Pressed")
}
inner class MyTester(var activity: AppCompatActivity) {
init {
addBackCB()
}
fun addBackCB() {
var callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
Log.v(TAG, "inner class MyTester back button")
}
}
activity.onBackPressedDispatcher.addCallback(activity, callback);
} …Run Code Online (Sandbox Code Playgroud) 我有问题,我找不到解决方案!我在 XML 中使用:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.libraryproject.MainActivity"
android:background="@android:color/holo_green_dark">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Main"
android:textSize="50dp"
android:id="@+id/textView"
android:layout_marginTop="200dp"
android:layout_marginLeft="130dp"/>
</RelativeLayout>
<android.support.design.widget.NavigationView ------! #32
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:menu="@menu/navigation_menu"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header"
android:id="@+id/nv">
</android.support.design.widget.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
错误显示是:android.view.InflateException: Binary XML file line #32: Binary XML file line #32: Error inflating class android.support.design.widget.NavigationView
在应用程序中:

java android android-navigationview material-components-android androidx
在将 flutter 升级到 v1.17.3 之前,一切正常,
已经尝试过:
flutter clean
Run Code Online (Sandbox Code Playgroud)
和
flutter downgrade
Run Code Online (Sandbox Code Playgroud)
我得到的错误(构建失败):
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\Shamuvel\Desktop\App Development\PROJECTS\Grocery Store\groci\android\Store\groci\android\app\src\main\AndroidManifest.xml:8:5-47:19: AAPT: error: attribute android:requestLegacyExternalStorage not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more …Run Code Online (Sandbox Code Playgroud) androidx ×10
android ×7
flutter ×2
gradle ×2
material-components-android ×2
android-architecture-components ×1
build-error ×1
cardview ×1
dart ×1
java ×1
jenkins ×1