Posts Tagged with
Android
After updating my app to compile with API level 30 (Android R, 11), I can’t see AdMob test ads, and I’m receiving this error in the log:
Strict Secure Cookie policy does not allow setting a secure cookie for http://googleads.g.doubleclick.net/ for apps targeting >= R. Please either use the ‘https:’ scheme for this URL or omit the ‘Secure’ directive in the cookie value.
I’m using the lastest AdMob version, and I don’t have “org.
Here is a sample of error message.
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0) Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0) Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0) Duplicate class kotlin.io.path.ExperimentalPathApi found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0) Duplicate class kotlin.io.path.PathRelativizer found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0) Duplicate class kotlin.io.path.PathsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.
Method 1 : Try Invalidating Android Studio Cache Just go File -> Invalidate Cache & Restart. So, Android Studio will remove cache and rebuild it and the project itself. If this solves the error, good for you. If not, try the next step.
Method 2 : Remove Unused Modules Click Command+Shift+F, type modules.xml, open the file, remove the modules that cause the error.
If the error persists, try the 3rd method.
Use the Flutter Profiler to identify performance issues.
Use the Flutter DevTools to debug your app.
Reduce the number of widgets in your app and use lazy loading where possible.
Use the Dart compiler to optimize your code for faster execution.
Use the latest version of Flutter and its dependencies for better performance.
Avoid using large images and videos in your app, instead use smaller versions or thumbnails where possible.
how to add a slidey notification into your Android project
in Drawable:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#C999" /> <corners android:topLeftRadius="10sp" android:topRightRadius="10sp"/> <stroke android:color="#000000" android:width="1sp"/> </shape> in your layout XML
<TextView android:id="@+id/Message" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center" android:layout_gravity="bottom" android:textSize="10pt" android:padding="10dp" android:textColor="@android:color/black" android:background="@drawable/popup_background" android:text="POPUP MESSAGE" /> in Java :
the whole gravity / layout_gravity is a bit confusing, so here is a snippet:
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:gravity="center_horizontal|bottom"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" Back " android:id="@+id/btn_back"/> </LinearLayout> The line of code that makes the button at the bottom is android:gravity="center_horizontal|bottom".
to get current project using mymodule in the ant build process. Add this line to default.properties in your Android project.
android.library.reference.1=../mymodule reference
If you already have a bitmap image in your code, just use this code snippet.
bmp = bmp.copy(Bitmap.Config.RGB_565, true); That code will recreate the bitmap image as a mutable. So you can edit that bitmap image on canvas as you like.
But if you do not have a bitmap image in code, create a new one using this code snippet.
Bitmap bmp=Bitmap.createBitmap(img.getHeight(),img.getWidth(),Bitmap.Config.RGB_565); where img is another bitmap image you want to make a new one with the height and width of it.
use android-gif-drawable library add the following dependency to build.gradle file of your project.
dependencies { implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' } Use the view in XML file like this.
<pl.droidsonroids.gif.GifImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/src_anim" android:background="@drawable/bg_anim" /> For more customization and code, see the docs here.
use VideoView on Android You can use VideoView to show the GIF image. But the library is more efficient and smooth.
use ImageView on Android Use ImageView and Split the GIF file into several images and then apply animation to it.
There are at least 3 ways to put imageview on another imageview.
Simple Order This way is just put the imageview after the other imageview in XML file. It is simple like that. The first view will be underneath the second one.
Using FrameLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/t" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> </FrameLayout> The second image will be on top.