1

Как только я превращаю это:

class MainActivity : AppCompatActivity() {
 override fun onCreate(savedInstanceState: Bundle?) {
 super.onCreate(savedInstanceState)
 setContentView(R.layout.activity_main)
 }
}

В это:

class MainActivity : AppCompatActivity() {
 private var binding: ActivityMainBinding? = null
 override fun onCreate(savedInstanceState: Bundle?) {
 super.onCreate(savedInstanceState)
 binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
 // запуск фрагмента Home (в данном случае он является фрагментом по умолчанию)
 supportFragmentManager.beginTransaction().replace(R.id.mainContent, ExchangeRateFragment()).commit()
 setSupportActionBar(binding?.topMainMenu)
 // обработчик нажатий по вкладнкам
 binding?.bottomMainMenu?.setOnItemSelectedListener { item ->
 when(item.itemId) {
 R.id.rateBottomMainMenu -> supportFragmentManager.beginTransaction().replace(R.id.mainContent, ExchangeRateFragment()).commit()
 R.id.favoriteBottomMainMenu -> supportFragmentManager.beginTransaction().replace(R.id.mainContent, FavouriteFragment()).commit()
 }
 return@setOnItemSelectedListener true
 }
 binding?.bottomMainMenu?.selectedItemId = R.id.rateBottomMainMenu
 }
}

Вылетает ошибка:

Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable

layout activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<layout 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"
 tools:context=".presentation.MainActivity">
 <androidx.constraintlayout.widget.ConstraintLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent">
 <androidx.appcompat.widget.LinearLayoutCompat
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical">
 <androidx.coordinatorlayout.widget.CoordinatorLayout
 android:id="@+id/sectTopMainMenu"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_weight="13.1">
 <com.google.android.material.appbar.AppBarLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <com.google.android.material.appbar.MaterialToolbar
 android:id="@+id/topMainMenu"
 android:layout_width="match_parent"
 android:layout_height="?attr/actionBarSize"
 android:background="@color/black"
 app:title="@string/app_name"
 app:titleTextColor="@color/white"
 style="@style/Widget.MaterialComponents.Toolbar.Primary"/>
 </com.google.android.material.appbar.AppBarLayout>
 </androidx.coordinatorlayout.widget.CoordinatorLayout>
 <FrameLayout
 android:id="@+id/mainContent"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_weight="1"/>
 </androidx.appcompat.widget.LinearLayoutCompat>
 <androidx.coordinatorlayout.widget.CoordinatorLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 app:layout_constraintBottom_toBottomOf="parent"
 app:layout_constraintEnd_toEndOf="parent"
 app:layout_constraintStart_toStartOf="parent">
 <com.google.android.material.bottomnavigation.BottomNavigationView
 android:id="@+id/bottomMainMenu"
 android:layout_width="match_parent"
 android:layout_height="?attr/actionBarSize"
 android:background="@color/black"
 android:elevation="16dp"
 app:itemIconTint="@color/tab_color"
 app:itemTextColor="@color/tab_color"
 app:menu="@menu/bottom_menu"/>
 </androidx.coordinatorlayout.widget.CoordinatorLayout>
 </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Содержимое Logcat:

2022年08月20日 22:47:23.745 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 22:47:24.746 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 22:47:24.746 1376-1376/? E/TLOC: [TLOCDaemon ]"Couldn't receive command response"
2022年08月20日 22:47:44.751 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 22:56:01.534 12921-13089/? E/ActivityThread: Failed to find provider info for androidx.car.app.connection
2022年08月20日 23:11:42.119 15868-15868/? E/LoadedApk: Unable to instantiate appComponentFactory
 java.lang.ClassNotFoundException: Didn't find class "com.northghost.touchvpn.whateverString" on path: DexPathList[[zip file "/data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/base.apk", zip file "/data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/split_config.arm64_v8a.apk", zip file "/data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/split_config.ru.apk", zip file "/data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/split_config.xhdpi.apk"],nativeLibraryDirectories=[/data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/lib/arm64, /data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/base.apk!/lib/arm64-v8a, /data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/split_config.ru.apk!/lib/arm64-v8a, /data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/split_config.xhdpi.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
 at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
 at android.app.LoadedApk.createAppFactory(LoadedApk.java:260)
 at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:902)

...

Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/split_config.xhdpi.apk
 at dalvik.system.DexFile.openDexFileNative(Native Method)
 at dalvik.system.DexFile.openDexFile(DexFile.java:367)
 at dalvik.system.DexFile.<init>(DexFile.java:109)
 at dalvik.system.DexFile.<init>(DexFile.java:82)
 at dalvik.system.DexPathList.loadDexFile(DexPathList.java:439)

...

2022年08月20日 23:11:42.383 15958-15958/? E/LoadedApk: Unable to instantiate appComponentFactory
 java.lang.ClassNotFoundException: Didn't find class "com.northghost.touchvpn.whateverString" on path: DexPathList[[zip file "/data/app/~~kc_kORywm37ObItXQVeUMQ==/com.northghost.touchvpn-EV0DrLrIWpwMdhR8yiJ1LQ==/base.apk", zip file 

...

2022年08月20日 23:17:44.766 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 23:17:45.767 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 23:17:45.767 1376-1376/? E/TLOC: [TLOCDaemon ]"Couldn't receive command response"
2022年08月20日 23:18:05.771 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 23:48:05.831 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 23:48:06.831 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"
2022年08月20日 23:48:06.831 1376-1376/? E/TLOC: [TLOCDaemon ]"Couldn't receive command response"
2022年08月20日 23:48:26.836 1376-1376/? E/TLOC: [TLOCChannel]"Can't receive message due to timeout"

build.dradle (Project):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
 ext.kotlin_version = "1.5.0"
 repositories {
 google()
 mavenCentral()
 }
 dependencies {
 classpath 'com.android.tools.build:gradle:7.2.2'
 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 // NOTE: Do not place your application dependencies here; they belong
 // in the individual module build.gradle files
 }
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
 id 'com.android.application' version '7.2.2' apply false
 id 'com.android.library' version '7.2.2' apply false
 id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
task clean(type: Delete) {
 delete rootProject.buildDir
}

build.gradle(Modele):

plugins {
 id 'com.android.application'
 id 'org.jetbrains.kotlin.android'
 id 'kotlin-kapt'
}
android {
 compileSdk 32
 defaultConfig {
 applicationId "com.sem.exchangerate"
 minSdk 21
 targetSdk 32
 versionCode 1
 versionName "1.0"
 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 multiDexEnabled true
 }
 buildTypes {
 release {
 minifyEnabled false
 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
 }
 }
 compileOptions {
 sourceCompatibility JavaVersion.VERSION_1_8
 targetCompatibility JavaVersion.VERSION_1_8
 }
 kotlinOptions {
 jvmTarget = '1.8'
 }
 dataBinding {
 enabled = true
 }
}
dependencies {
 implementation 'androidx.legacy:legacy-support-v4:1.0.0'
 def retrofit_version = "2.9.0"
 def room_version = '2.4.3'
 def lifecycle_version = '2.5.1'
 def arch_version = "2.1.0"
 def coroutines_version = '1.6.4'
 def koin_version = '3.2.0'
 def picasso = "2.71828"
 def multidex_version = "2.0.1"
 implementation "androidx.multidex:multidex:$multidex_version"
 implementation 'androidx.core:core-ktx:1.8.0'
 implementation 'androidx.appcompat:appcompat:1.5.0'
 implementation 'com.google.android.material:material:1.6.1'
 implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
 testImplementation 'junit:junit:4.13.2'
 androidTestImplementation 'androidx.test.ext:junit:1.1.3'
 androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
 implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
 implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
 implementation "androidx.room:room-runtime:$room_version"
 kapt "androidx.room:room-compiler:$room_version"
 implementation "androidx.room:room-ktx:$room_version"
 // ViewModel
 implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
 // LiveData
 implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
 // Lifecycles only (without ViewModel or LiveData)
 implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
 // Saved state module for ViewModel
 implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
 // Annotation processor
 //noinspection LifecycleAnnotationProcessorWithJava8
 kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
 // Koin main features for Android (Scope,ViewModel ...)
 implementation "io.insert-koin:koin-android:$koin_version"
 // Koin Java Compatibility
 implementation "io.insert-koin:koin-android-compat:$koin_version"
 implementation "com.squareup.picasso:picasso:$picasso"
}
задан 21 авг. 2022 в 8:00
4
  • Не очень понятно при чем здесь впн какой-то, подключить можно multidex в градл как вариант, но все равно странно это всё Commented 21 авг. 2022 в 8:58
  • Покажите build.gradle. возможно вы что-то подключить забыли Commented 21 авг. 2022 в 9:25
  • @Andrew, попробовал подключить def multidex_version = "2.0.1" implementation "androidx.multidex:multidex:$multidex_version", не помогло Commented 21 авг. 2022 в 9:45
  • @ЮрийСПб, build.gradle добавил в текст вопроса Commented 21 авг. 2022 в 9:49

1 ответ 1

1

Как оказалось, нужно было удалить

android:layout_width="match_parent"
android:layout_height="match_parent"

из

<layout 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"
 tools:context=".presentation.MainActivity">

чтобы получилось:

<?xml version="1.0" encoding="utf-8"?>
<layout 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"
 tools:context=".presentation.MainActivity">
 <androidx.constraintlayout.widget.ConstraintLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent">
 <androidx.appcompat.widget.LinearLayoutCompat
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical">
 <androidx.coordinatorlayout.widget.CoordinatorLayout
 android:id="@+id/sectTopMainMenu"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_weight="13.1">
 <com.google.android.material.appbar.AppBarLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <com.google.android.material.appbar.MaterialToolbar
 android:id="@+id/topMainMenu"
 android:layout_width="match_parent"
 android:layout_height="?attr/actionBarSize"
 android:background="@color/black"
 app:title="@string/app_name"
 app:titleTextColor="@color/white"
 style="@style/Widget.MaterialComponents.Toolbar.Primary"/>
 </com.google.android.material.appbar.AppBarLayout>
 </androidx.coordinatorlayout.widget.CoordinatorLayout>
 <FrameLayout
 android:id="@+id/mainContent"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_weight="1"/>
 </androidx.appcompat.widget.LinearLayoutCompat>
 <androidx.coordinatorlayout.widget.CoordinatorLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 app:layout_constraintBottom_toBottomOf="parent"
 app:layout_constraintEnd_toEndOf="parent"
 app:layout_constraintStart_toStartOf="parent">
 <com.google.android.material.bottomnavigation.BottomNavigationView
 android:id="@+id/bottomMainMenu"
 android:layout_width="match_parent"
 android:layout_height="?attr/actionBarSize"
 android:background="@color/black"
 android:elevation="16dp"
 app:itemIconTint="@color/tab_color"
 app:itemTextColor="@color/tab_color"
 app:menu="@menu/bottom_menu"/>
 </androidx.coordinatorlayout.widget.CoordinatorLayout>
 </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Теперь всё работает

ответ дан 21 авг. 2022 в 10:09

Ваш ответ

Черновик сохранён
Черновик удалён

Зарегистрируйтесь или войдите

Регистрация через Google
Регистрация через почту

Отправить без регистрации

Необходима, но никому не показывается

Отправить без регистрации

Необходима, но никому не показывается

Нажимая «Отправить ответ», вы соглашаетесь с условиями пользования и подтверждаете, что прочитали политику конфиденциальности.