When I try to make changes to the splash screen and reinstall the application, the splash does not change.
It's strange that sometimes (the next day) changes are picked up on the first build. It`s really magic that splash stay the same when I change color and reinstall app.
I am debugging on ZTE Benefit M8 Android 7.1.2 (custom firmware).
app module->res folders:
values/splash_theme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App.Starting1" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#069056</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
<item name="postSplashScreenTheme">#style/Theme.NextTheme</item>
</style>
</resources>
values-night/splash_theme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App.Starting1" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#ff1212</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
<item name="postSplashScreenTheme">#style/Theme.NextTheme</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="myApp.app.App"
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:targetApi="31">
<activity
android:name="myApp.presentation.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:theme="#style/Theme.App.Starting1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle.kts
plugins {
id(Dependencies.Plugins.application)
id(Dependencies.Plugins.kotlin)
id(Dependencies.Plugins.kapt)
id(Dependencies.Plugins.serialization)
id(Dependencies.Plugins.parcelize)
}
android {
namespace = Config.Namespace.App
compileSdk = Config.Sdk.compile
defaultConfig {
applicationId = Config.applicationId
minSdk = Config.Sdk.min
targetSdk = Config.Sdk.target
versionCode = Config.Versions.code
versionName = Config.Versions.name
testInstrumentationRunner = Config.Test.instrumentationRunner
}
buildTypes {
release {
isMinifyEnabled = Config.Release.minifyEnabled // false
proguardFiles(
getDefaultProguardFile(Config.Release.Proguard.name),
Config.Release.Proguard.rules
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = Config.Kotlin.Options.jvmTarget
}
buildFeatures {
viewBinding = true
}
}
dependencies {
implementation(project(":core"))
implementation(project(":core-ui"))
implementation(Dependencies.Default.core)
implementation(Dependencies.Default.appCompat)
implementation(Dependencies.Default.material)
//Activity
implementation(Dependencies.Lifecycle.activity)
//Fragment
implementation(Dependencies.Lifecycle.fragment)
// ViewModel
implementation(Dependencies.Lifecycle.viewModel)
// Lifecycle
implementation(Dependencies.Lifecycle.lifecycle)
kapt(Dependencies.Lifecycle.lifecycleCompiler)
//Splash
implementation(Dependencies.splash) // androidx.core:core-splashscreen:1.0.0
...
}
MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
getAppComponent().inject(this)
binding = ActivityMainBinding.inflate(layoutInflater)
.apply { setContentView(root) }
I try: invalid cache, restart, rebuild, clean, reinstalling dependencies by ./gradlew, reopen studio, delete app on device, rename splash theme, reconnect device with usb.
Related
I have a fragments displaying lists of items and it's forms to populate the lists.
When i go to the list fragment to the form fragment using findNavController().navigate() the form fragment is shown only on the 50% of the screen, after a couple seconds it finishs showing the other 50%. If i scroll the screen the fragments shows it´s 100% instantly, if i idle and do not touch the screen it takes several seconds.
In some of the fragment transacction the glitch is not random, meaning i can reproduce it every time i make that findNavController().navigate().
But there are other cases where the glitch happens sometimes and some other times it does not.
This is happening in emulator and in real devices also.
This is how it looks like (this is the one i can reproduce)
This is how i nav from list fragment to form fragment. Backwards i use the generated backwards button at the left top corner.
findNavController().navigate(
R.id.nav_form_automovil,
args = b
)
I may add that i am using abstract generic clases that i created to reutilize code. The glitchs started happening around that time.
abstract class BaseListItemFragment<T, B : ViewBinding, F : BaseFormState>(#LayoutRes id: Int) :
BaseItemFragment<T, B, F>(id) {
private var _recyclerView: RecyclerView? = null
private var _adapter: BaseAdapter<T>? = null
fun initRecycler(recyclerView: RecyclerView, adapter: BaseAdapter<T>) {
_recyclerView = recyclerView
_recyclerView?.layoutManager =
LinearLayoutManager(
MainApplication.instance.applicationContext,
LinearLayoutManager.VERTICAL,
false
)
_adapter = adapter
_recyclerView?.adapter = _adapter
}
private fun observeItemList() =
viewModel?.itemList?.observe(viewLifecycleOwner, Observer {
val itemList = it ?: return#Observer
viewModel?.updateIsLoading(false)
if (itemList.isNotEmpty()) {
_adapter?.updateModels(itemList)
_recyclerView?.smoothScrollToPosition(0)
}
})
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
observeItemList()
}
override fun onResume() {
super.onResume()
viewModel?.fetchAndObserve()
}
}
abstract class BaseItemFragment<T, B : ViewBinding, F : BaseFormState>(#LayoutRes id: Int) :
Fragment(id) {
private var _binding: B? = null
val binding get() = _binding
var viewModel: BaseItemViewModel<T, F>? = null
fun inflateLayout(viewBinding: B) {
_binding = viewBinding
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
provideViewModels()
return super.onCreateView(inflater, container, savedInstanceState)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
enableLoadingScreen()
observeLogoutFlag()
setUpListeners(view)
}
private fun observeLogoutFlag() =
viewModel?.refreshTokenExpired?.observe(viewLifecycleOwner, Observer {
val isExpired = it ?: return#Observer
if (isExpired) {
activity?.finish()
}
})
abstract fun enableLoadingScreen()
abstract fun setUpListeners(view: View)
abstract fun provideViewModels()
//** Extension functions start here **//
/**
* Extension function to simplify setting an afterTextChanged action to EditText components.
*/
fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) {
this.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(editable: Editable?) {
afterTextChanged.invoke(editable.toString())
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
})
}
fun Int.toDp(context: Context): Int = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, this.toFloat(), context.resources.displayMetrics
).toInt()
}
Provided a viewModel instance my fragments usually performs 1 or 2 or 3 network operations with IO dispatcher, most common case
override fun onResume() {
super.onResume()
viewModel?.fetchAndObserve()
}
Implementations look like this.
class AutomovilListFragment() :
BaseListItemFragment<Automovil, FragmentListAutomovilBinding, AutomovilFormState>(
R.layout.fragment_list_automovil
) {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
super.onCreateView(inflater, container, savedInstanceState)
inflateLayout(FragmentListAutomovilBinding.inflate(inflater, container, false))
initRecycler(
binding!!.listAuto,
AutomovilAdapter(ArrayList(), WeakReference(this))
)
return binding!!.root
}
override fun setUpListeners(view: View) {
}
override fun enableLoadingScreen() {
viewModel?.isLoading?.observe(viewLifecycleOwner, Observer {
val isLoading = it ?: return#Observer
if (isLoading) binding!!.pBarListAutomovil.visibility = View.VISIBLE
else binding!!.pBarListAutomovil.visibility = View.INVISIBLE
})
}
override fun provideViewModels() {
viewModel =
ViewModelProvider(
requireActivity(),
AutomovilViewModelFactory()
)[AutomovilViewModel::class.java]
}
}
Do anyone see what could be the root cause of this and what route take to find a solution?
EDIT: Added Example Layout, Navigation XML, Build Gradle Files and Manifests
Example Layout:
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.qsafe.appKmm.android.ui.fragment.automovil.AutomovilListFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/listAuto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/pBarListAutomovil"
style="#style/Theme.qsafe.loading.TranslucentBackground"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="0sp"
android:layout_marginTop="0sp"
android:layout_marginEnd="0sp"
android:layout_marginBottom="0sp"
android:clickable="true"
android:focusable="true"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ProgressBar
android:id="#+id/progressBarListAutomovil"
style="#android:style/Widget.Holo.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.qsafe.appKmm.android">
<supports-screens
android:anyDensity="false"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="com.qsafe.appKmm.android.MainApplication"
android:icon="#drawable/qsafe_logo_sin_texto"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/Theme.qsafe.residente"
android:usesCleartextTraffic="true"
tools:targetApi="s">
<activity
android:name="com.qsafe.appKmm.android.ui.MainActivity"
android:configChanges="orientation"
android:label="Inicio"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="com.qsafe.appKmm.android.login.LoginActivity"
android:configChanges="orientation"
android:exported="true"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="com.qsafe.appKmm.android.login.LoginSplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="sistema.qsafe.mx"
android:pathPattern="/Account/Login"
android:scheme="http" />
</intent-filter>
</activity>
<activity
android:name="com.qsafe.appKmm.android.login.pass.PassForgotActivity"
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="sistema.qsafe.mx"
android:pathPattern="/Account/ForgotPassword"
android:scheme="http" />
</intent-filter>
</activity>
<activity
android:name="com.qsafe.appKmm.android.login.pass.PassResetActivity"
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="sistema.qsafe.mx"
android:pathPattern="/Account/ResetPassword"
android:scheme="http" />
</intent-filter>
</activity>
<service
android:name="com.qsafe.appKmm.android.com.qsafe.appkmm.android.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/qsafe_logo_sin_texto" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/cardview_light_background" />
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="appKmm.appKmm.MySqlDelightInitializer"
tools:node="remove" />
</provider>
</application>
</manifest>
App Build gradle
plugins {
//trick: for the same plugin versions in all sub-modules
id("com.android.application").version("7.2.0").apply(false)
id("com.android.library").version("7.2.0").apply(false)
kotlin("android").version("1.7.10").apply(false)
kotlin("multiplatform").version("1.7.10").apply(false)
}
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
classpath("com.android.tools.build:gradle:7.1.3")
classpath("com.google.gms:google-services:4.3.14")
classpath("org.jetbrains.kotlin:kotlin-serialization:1.7.10")
classpath("com.squareup.sqldelight:gradle-plugin:1.5.3")
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
setUrl("https://oss.sonatype.org/content/repositories/snapshots/")
}
maven {
setUrl("https://jitpack.io")
}
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
Android Build Gradle:
plugins {
id("com.android.application")
id("com.google.gms.google-services")
kotlin("android")
id("kotlin-android-extensions")
}
android {
compileSdk = 32
defaultConfig {
applicationId = "com.qsafe.appKmm.android"
minSdk = 26
targetSdk = 32
versionCode = 3
versionName = "3"
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
}
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding = true
dataBinding = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
//QUADRO
implementation(project(":shared"))
//ANDROIDX
implementation("androidx.fragment:fragment-ktx:1.5.3")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("androidx.navigation:navigation-fragment-ktx:2.5.2")
//implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.navigation:navigation-ui-ktx:2.5.2")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.5.1")
implementation("androidx.work:work-runtime-ktx:2.7.1")
implementation("androidx.security:security-crypto:1.1.0-alpha03")
//JETBRAINS
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1")
//GOOGLE
implementation("com.google.android.material:material:1.6.1")
implementation("com.google.code.gson:gson:2.9.0")
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
implementation("com.google.firebase:firebase-core:21.1.1")
implementation("com.google.firebase:firebase-messaging-ktx:23.0.8")
implementation("com.google.firebase:firebase-common-ktx:20.1.2")
implementation("com.google.firebase:firebase-analytics-ktx:21.1.1")
//SQUAREUP
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("com.squareup.okhttp3:okhttp:3.14.9")
implementation("com.squareup.okhttp3:logging-interceptor:3.14.0")
//TOASTY
implementation ("com.github.GrenderG:Toasty:1.5.2")
}
Shared Module KMM build gradle:
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
val ktor_version = "2.0.1"
val coroutines_version = "1.6.0"
val kotlinx_serialization_version = "1.3.2"
val sqldelight_version = "1.5.3"
val arkitekt_version = "0.1.1-SNAPSHOT"
plugins {
id("com.android.library")
id("com.squareup.sqldelight")
kotlin("multiplatform")
kotlin("plugin.serialization")
kotlin("native.cocoapods")
}
version = "1.0"
sqldelight {
database("CommonDatabase") {
packageName = "com.qsafe.appKmm.db"
sourceFolders = listOf("sqldelight")
}
}
kotlin {
android()
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iosTarget("ios") {}
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
ios.deploymentTarget = "12.4"
framework {
baseName = "shared"
}
podfile = project.file("../Qsafe/Podfile")
}
sourceSets {
val commonMain by getting {
dependencies {
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
// Serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinx_serialization_version")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinx_serialization_version")
// Ktor
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-auth:$ktor_version")
implementation("io.ktor:ktor-client-json:$ktor_version")
implementation("io.ktor:ktor-client-serialization:$ktor_version")
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")
implementation("io.ktor:ktor-client-logging:$ktor_version")
// SqlDelight
implementation("com.squareup.sqldelight:runtime:$sqldelight_version")
implementation("com.squareup.sqldelight:coroutines-extensions:$sqldelight_version")
// Arkitekt
api("app.futured.arkitekt:km-usecases:$arkitekt_version")
implementation(kotlin("script-runtime"))
//Kodein dependency injection
implementation("org.kodein.di:kodein-di:7.10.0")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
// Ktor android engine
implementation("io.ktor:ktor-client-android:$ktor_version")
// SqlDelight android driver
implementation("com.squareup.sqldelight:android-driver:$sqldelight_version")
//App Startup
implementation("androidx.startup:startup-runtime:1.1.1")
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
}
}
val iosMain by getting {
dependencies {
// Ktor ios engine
implementation("io.ktor:ktor-client-ios:$ktor_version")
// SqlDelight iOS driver
implementation("com.squareup.sqldelight:native-driver:$sqldelight_version")
// Arkitekt viewmodel
api("app.futured.arkitekt:km-viewmodel:0.1.2-SNAPSHOT")
}
}
val iosTest by getting
}
}
android {
compileSdk = 32
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 24
targetSdk = 32
}
}
Navigation XML file:
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="#+id/mobile_navigation"
app:startDestination="#+id/nav_bitacora">
<fragment
android:id="#+id/nav_bitacora"
android:name="com.qsafe.appKmm.android.ui.fragment.bitacora.BitacoraListFragment"
android:label="Inicio"
app:enterAnim="#android:anim/fade_in"
app:exitAnim="#android:anim/fade_out"
app:popEnterAnim="#anim/nav_default_pop_enter_anim"
app:popExitAnim="#anim/nav_default_pop_exit_anim"
tools:layout="#layout/fragment_list_bitacora">
<action
android:id="#+id/action_nav_bitacora_to_nav_settings"
app:destination="#id/nav_settings"
app:enterAnim="#android:anim/fade_in"
app:exitAnim="#android:anim/fade_out"
app:popEnterAnim="#anim/nav_default_pop_enter_anim"
app:popExitAnim="#anim/nav_default_pop_exit_anim" />
<action
android:id="#+id/action_nav_bitacora_to_nav_automoviles"
app:destination="#id/nav_automovil"
app:enterAnim="#android:anim/fade_in"
app:exitAnim="#android:anim/fade_out"
app:popEnterAnim="#anim/nav_default_pop_enter_anim"
app:popExitAnim="#anim/nav_default_pop_exit_anim" />
<action
<fragment
android:id="#+id/nav_automovil"
android:name="com.qsafe.appKmm.android.ui.fragment.automovil.AutomovilListFragment"
android:label="Automóviles"
tools:layout="#layout/fragment_list_automovil">
<action
android:id="#+id/action_nav_automovil_to_nav_form_automovil"
app:destination="#id/nav_form_automovil"
app:enterAnim="#android:anim/fade_in"
app:exitAnim="#android:anim/fade_out"
app:popEnterAnim="#anim/nav_default_pop_enter_anim"
app:popExitAnim="#anim/nav_default_pop_exit_anim" />
</fragment>
<fragment
android:id="#+id/nav_form_automovil"
android:name="com.qsafe.appKmm.android.ui.fragment.automovil.FormAutomovilFragment"
android:label="Guardar automóvil"
tools:layout="#layout/fragment_form_automovil">
<action
android:id="#+id/action_nav_form_automovil_to_nav_automovil"
app:destination="#id/nav_automovil"
app:enterAnim="#android:anim/fade_in"
app:exitAnim="#android:anim/fade_out"
app:popEnterAnim="#anim/nav_default_pop_enter_anim"
app:popExitAnim="#anim/nav_default_pop_exit_anim" />
</fragment>
.... some more fragment navigations ...
</navigation>
My Flutter app is showing a blank white screen with the following errors when building a signed --release version to run on a physical device:
W/FlutterActivity(24374): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.a#10d90e5) but could not find and invoke the GeneratedPluginRegistrant.
E/flutter (24374): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
Everything works fine when running in debug.
These are what my various files look like:
MainActivity.kt
package my.app.id
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
Application.kt
This was done done because firebase messaging wasnt working, and recommened everywhere online, and fixed my problems, in debug mode at least.
package my.app.id
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
override fun registerWith(registry: PluginRegistry) {
FirebaseCloudMessagingPluginRegistrant.registerWith(registry)
}
}
FirebaseCloudMessagingPluginRegistrant.kt
package my.app.id
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin
class FirebaseCloudMessagingPluginRegistrant {
companion object {
fun registerWith(registry: PluginRegistry) {
if (alreadyRegisteredWith(registry)) {
return;
}
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
}
fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
val key = FirebaseCloudMessagingPluginRegistrant::class.java.name
if (registry.hasPlugin(key)) {
return true
}
registry.registrarFor(key)
return false
}
}
}
AndroidManifest.xml (Parts of it)
...
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".Application"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
...
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
...
<meta-data
android:name="flutterEmbedding"
android:value="2" />
build.gradle
defaultConfig {
applicationId "my.app.id"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
...
buildTypes {
release {
minifyEnabled true
}
}
...
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version'
implementation 'com.google.firebase:firebase-messaging:20.2.3'
implementation 'com.google.firebase:firebase-auth:19.3.2'
}
I've tried everything I know of to figure this out but can't. Im here to give any more info needed, thanks for the help!
[related code for error in MainActivity.kt][2]
I have tried fn+option+return(Mac IOS) for import purpose, but still not working. Same as trying invalidate caches and restart. They are not working!
I just follow the lecture which is given by the professor step by step. The version for the Android studio on my macbook is 3.5.1
Looking for help.
I also met another error. Here is the code for the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.assignment3muyaozhang0882423" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:value="#integer/google_play_services_version" />
<activity android:name=".Floating_label" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" >
</activity>
</application>
</manifest>
The error I met which is sync error:
ERROR: Failed to parse XML in /Users/kitty/Downloads/Assignment2MuyaoZhang0882423/app/src/main/AndroidManifest.xml
org.xml.sax.SAXParseException; systemId: file:/Users/kitty/Downloads/Assignment2MuyaoZhang0882423/app/src/main/AndroidManifest.xml; lineNumber: 23; columnNumber: 4; 元素类型 "manifest" 必须由匹配的结束标记 "" 终止。
Affected Modules: app
The code for app:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.assignment3muyaozhang0882423"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = kotlin_version
targetCompatibility = kotlin_version
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:29.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
code for kt file:
package com.example.assignment3muyaozhang0882423
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.R
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import android.widget.Toast.makeText
class setion2 : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_setion2)
val usernamestring = text_Person_Name.text
val passwordstring = text_Password.text
val con_btn = (Button) findViewById(R.id.con_btn) as Button
con_btn.isAllCaps = false
con_btn.setOnClickListener {
if (this.usernamestring.isNotEmpty() && this.passwordstring.isNotEmpty())
{
val message =
"User Name: " + usernamestring + "\n" + "Password: " + this.passwordstring
Toast.makeText(this, message, LENGTH_LONG).show()
} else {
Toast.makeText(this, "Please enter valid input", LENGTH_LONG).show()
}
}
}
}
Please check out my reply on your comment too.
Click on the error of text_layout and send the relevant code.
It is LinearLayout.LayoutParams.MATCH_PARENT
the underscore is missing between MATCH and PARENT
I am kind of newbie in Android Programming, So I Just want to Display Mopub banner ad in my app. I created the Sample app, also created Ad unit id in Mopub.
I successfully integrated SDK and following their https://developers.mopub.com/docs/android/banner/ instructions on this page.
but I don't know why my app which is Live on G-play Only sending the request but no impression. I also checked on my Phone & its true. No ads are displaying. Here is My Code
Can anyone Help me Please?
mainactivity.java:-
import com.mopub.mobileads.MoPubErrorCode;
import com.mopub.mobileads.MoPubView;
import static com.mopub.mobileads.MoPubView.BannerAdListener;
public class MainActivity extends AppCompatActivity implements BannerAdListener {
private MoPubView mBanner;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBanner = (MoPubView) findViewById(R.id.bannerview);
mBanner.setAdUnitId("XXXXXXXXXXXXXXXXXXXXXXXX"); // Enter your Ad Unit ID from www.mopub.com
mBanner.setBannerAdListener(this);
mBanner.loadAd();
}
#Override
protected void onDestroy() {
mBanner.destroy();
super.onDestroy();
}
#Override
public void onBannerLoaded(MoPubView banner) {
Log.d("MoPub Demo", "Banner loaded callback.");
}
#Override
public void onBannerFailed(MoPubView banner, MoPubErrorCode errorCode) {
Log.d("MoPub Demo", "Banner failed callback with: " + errorCode.toString());
}
#Override
public void onBannerClicked(MoPubView banner) {
Log.d("MoPub Demo", "Banner clicked callback.");
}
#Override
public void onBannerExpanded(MoPubView banner) {
Log.d("MoPub Demo", "Banner expanded callback.");
}
#Override
public void onBannerCollapsed(MoPubView banner) {
Log.d("MoPub Demo", "Banner collapsed callback.");
}
}
Activity_main.xml:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mopub.mobileads.MoPubView
android:id="#+id/bannerview"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Build.gradle(module.app):-
repositories {
// ... other project repositories
jcenter() // includes the MoPub SDK and AVID library
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.your.prject.appmopubtest"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation('com.mopub:mopub-sdk:4.20.0#aar') {
transitive = true
}
}
Build.gradle(project.appmopubtest):-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
androidmanifest.xml:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.your.prject.appmopubtest">
<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Optional permissions. Will pass Lat/Lon values when available. Choose either Coarse or Fine -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- All ad formats -->
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Interstitials -->
<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Rewarded Video and Rewarded Playables -->
<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
</application>
</manifest>
I've created following project in Android Studio, and clicked on "Run" button in Android Studio to run the app.
In my mind, Android Studio will run the app with debug model, but what will Toast display? will it display the one of following options?
A: com.example.my.myapplication FLAVOR free
B: com.example.my.myapplication FLAVOR pro
C: info.dodata.messagecleanup FLAVOR free
D: info.dodata.messagecleanup FLAVOR pro
MainActivity.java
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String versionName = getPackageName()+" FLAVOR "+BuildConfig.FLAVOR;
if (BuildConfig.FLAVOR == "pro") {
Toast.makeText(getApplicationContext(), versionName, Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), versionName , Toast.LENGTH_LONG).show();
}
}
}
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.my.myapplication"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
productFlavors {
free {
applicationId "info.dodata.messagecleanup"
}
pro {
applicationId "info.dodata.messagecleanup.pro"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>