I get Cannot resolve symbol FirebaseVisionTextDetector error when I put in my module:
import com.google.firebase.ml.vision.text.FirebaseVisionTextDetector;
I can't understand why because in gradle I have the correct implementation:
implementation 'com.google.firebase:firebase-ml-vision:18.0.1'
SOLVED
I have solved by downgrading to 16.0.0. Still don't know the reason why.
implementation 'com.google.firebase:firebase-ml-vision:16.0.0'
Downgrade is not really a solution. There are many bug fixes and upgrades which you should ship with your app.
FirebaseVisionTextDetector class was removed in
firebase-ml-vision:17.0.0 , it was last available in firebase-ml-vision:16.0.0 they have changed it to FirebaseVisionTextRecognizer.
There are not much difference between both classes. So go ahead and do changes.
Changes to make:
Before (v-16.0.0):
FirebaseVisionTextDetector
FirebaseVisionTextDetector.detectInImage(image)
List<FirebaseVisionText.Block> resultsBlocks = results.getBlocks();
for (FirebaseVisionText.Block block : resultsBlocks) {
for (FirebaseVisionText.Line line : block.getLines()) {
//...
}
}
After (v-18.0.1):
FirebaseVisionTextRecognizer
FirebaseVisionTextDetector.processImage(image)
List<FirebaseVisionText.TextBlock> blocks = results.getTextBlocks();
for (FirebaseVisionText.TextBlock block : blocks) {
// ...
}
}
You can clone Official ML kit sample project to see complete code implementation.
Please check link for list of class and interface which ML kit provide in vision.text package. so I guess you need to take help from FirebaseVisionTextRecognizer class.
Here is the example how you can use 'FirebaseVisionTextRecognizer' class.
Related
I've an Android app using retrofit 2 and okhttp for its json requests. everything was going fine until android studio(AS) oferred me the update from 3.9.6 to 4.1
The update is done easily inside the AS and it also updates the gradle plugin.
Once the update was finished I rebuild and compiled a new aab, then i notice the new file generated was 100kb smaller than the previous one (altough no code or assets changes were made, only the IDE version updated)... then i release on google play and download it in my test device (real phone). It didn't work. The app opens but it is not able to perform any okhttp request
I tried to run inside AS emulator -> it worked fine.
I tried to run in the emulator with minifyEnabled true shrinkResources true -> it worked fine
so i added to the code several debug calls in order to let me know exaclty until what line the app was working.... and i got.
try {
okHttpClient.newCall(new Request.Builder().get().url("https://www.google.com").build()).execute();
return true;
} catch (Exception e) {
return false;
}
this is a little snippet i use to test if user has internet connection.
No exception is thrown, no value is returned, the call simple dive into the okhttp api and never come back...
So i want to let clear: no code was changed, no api was updated, no r8 rules was changed
the only thing changed was the AS updated from 3.9.6 to 4.1 and some mandatory gradle plugin updated as well
after that the signed aab built got 100kb smaller and this very weird behavior started happening...
I've already tried EVERYTHING i can, but still no idea how to solve. does anyone ever face a similar problem or have idea what to do?
there are my imports
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation('com.facebook.android:facebook-login:5.13.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
//retrofit
implementation('com.squareup.retrofit2:retrofit:2.9.0') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation "com.squareup.okhttp3:okhttp:4.10.0-RC1"
implementation 'com.squareup.okio:okio:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation('com.squareup.retrofit2:converter-gson:2.9.0') {
exclude group: "com.google.code.gson", module: "gson"
}
I've already tried EVERYTHING i can, but still no idea how to solve. does anyone ever face a similar problem or have idea what to do?
Yes, everyone faces these problems. It's part of the learning process of being a developer. Stop focusing on this particular problem with this library for a minute and ask why you are stuck and how to get unstuck. If you reported this to a library maintainer this is what they would need to do, which is why they would ask for a clean reproduction.
Firstly read http://sscce.org/ and understand what it means and why the above question isn't getting answers. It's not a clean reproduction, it's a few random lines of code.
Then ask a a colleague to help you use a debugger, where is it stuck, what are the threads doing or waiting on.
Use the features of the library e.g. add an OkHttp Event Listener https://square.github.io/okhttp/events/.
Going back the SSCCE example, make a small example project reproducing the issue and post it to a temporary github project, then report that as a bug to OkHttp project. They can just check out the project and run it to reproduce then.
For me, I was trying to fetch data using a retrofit. Getting 400 on release build. My model was like the following:
data class ContentIdAddRQ(
#SerializedName("contentId")
val contentId: String? = null,
#SerializedName("contentType")
val contentType: String? = "VOD",
)
Then I tried adding #Keep annotation to my Model file as shown below:
#Keep
data class ContentIdAddRQ(
#SerializedName("contentId")
val contentId: String? = null,
#SerializedName("contentType")
val contentType: String? = "VOD",
)
Here's code snippet from google/exoplayer - which is written in Groovy buildscript.
// settings.gradle
gradle.ext.exoplayerRoot = 'path/to/exoplayer'
gradle.ext.exoplayerModulePrefix = 'exoplayer-'
apply from: new File(gradle.ext.exoplayerRoot, 'core_settings.gradle')
How can I achieve this using Kotlin DSL?
I couldn't find any useful resources or documents. Any help would be appreciated.
Found a solution after digging a while.
In Groovy, there's dynamic implementation of traits - So even if class A does not implement interface B in the class definition, it may implement it later in the future.
I didn't see Gradle internals so I can't properly explain this, but it seems to work. Hope this helps.
if (gradle is ExtensionAware) {
val extension = gradle as ExtensionAware
extension.extra["exoplayerRoot"] = "path/to/exoplayer"
extension.extra["exoplayerModulePrefix"] = "exoplayer-"
apply(from = File(extension.extra["exoplayerRoot"].toString(), "core_settings.gradle"))
}
For those who uses ExoPlayer, I created an issue for requesting some documents for Kotlin DSL users.
I am trying to customize the firebase in-app-messaging-display's UI of "Image Only" and "Modal" mode. So I turned to the official documentation, but it is quite simple, by saying:
Creating your own display is a two step process:
1.Write your own implementation of the FirebaseInAppMessagingDisplay class.
2.Register that implemenation with the headless Firebase In-App Messaging SDK.
I wonder how can I import in-app-messaging-display's source code into my project and make it work as a library.
I have downloaded its source code from github:https://github.com/firebase/firebase-android-sdk/tree/master/firebase-inappmessaging-display, tried to import it as a module, but after I selected the Source directory, Android Studio hints that: Specify location of the Gradle
or Android Eclipse project. I also have tried to copy the source code into my project's libs directory and added this: include ':libs:firebase-inappmessaging-display' into my settings.gradle file and this: implementation project(':libs:firebase-inappmessaging-display') into my app's gradle dependency. When sync building Android Studio reports errors like this:
ERROR: Unable to resolve dependency for ':XXXXXXXX': Could not resolve project :libs:firebase-inappmessaging-display.
Any suggestion will be highly appreciated.
The information on the doc is little bit confusing. I am also stuck with the same problem for long time. Actually its very simple.
Add these dependencies in your app level gradle file.
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation ("com.google.firebase:firebase-inappmessaging:17.0.3")
Register Your DisplayMessage component on starting activity.
import com.google.firebase.inappmessaging.FirebaseInAppMessaging
import com.google.firebase.inappmessaging.FirebaseInAppMessagingDisplay
///////
override fun onStart() {
super.onStart()
Log.e("MESSAGE", "activity started")
var firebaseInAppMessagingDisplay = FirebaseInAppMessagingDisplay { inAppMessage, cb ->
// You can show the message here.
// The variable inAppMessage has all information about the campaign that we putting in console (title, content, image url.. etc)
Log.e("MESSAGE", "Display Message callback invoked")
}
FirebaseInAppMessaging.getInstance().setMessageDisplayComponent(firebaseInAppMessagingDisplay)
}
Timber is a great library for logging in Android. In Kotlin classes though, doesn't output anything. How can I fix this?
MainActivity.kt code:
Timber.e("Timber Log 1")
Log.e("MainActivity", "Log 1")
Gradle:
I've tried the regular Java Timber:
implementation 'com.jakewharton.timber:timber:4.7.1'
And this Kotlin specific wrapper:
implementation 'com.github.ajalt:timberkt:1.5.1'
Same result. No output with either. Only from the Log.e()
The first step of Timber is to plant the tree as mentioned in docs
Behavior is added through Tree instances. You can install an instance
by calling Timber.plant. Installation of Trees should be done as early
as possible. The onCreate of your application is the most logical
choice.
And use the debugTree
The DebugTree implementation will automatically figure out from which
class it's being called and use that class name as its tag. Since the
tags vary
If you don't do this then you will have no logs entry and do this as soon as possible, like in oncreate or better inside application class so do this
Timber.plant(Timber.DebugTree());
I have faced same problem, using Kotlin and Android studio 3.6
Follow these steps:
Add the following in build.gradle(Module: App)
implementation 'com.jakewharton.timber:timber:4.7.1'
Initialize Timber in Application Class:
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
if(BuildConfig.DEBUG){
Timber.plant(Timber.DebugTree())
}
}
}
Add the Application class(MyApp) to the Manifest (AndroidManifest.xml)
<application
android:name=".MyApp"
Now you can use Timber: Timber.i("Timber logs")
Also can use custom tags if you wish: Timber.tag("Yo").I("used custom tag for logs")
In my case it was wrong BuildConfig import
import org.koin.android.BuildConfig
but my app has
import com.company.example.BuildConfig
Probably late to the party but my problem was the my phone was set to "Charge only" and not "file transfer". Apparently I was allowed to build and run, but logs were blocked
EDIT Another solution:
Check your RUN tab in the bottom of Android Studio. Sometimes the logs get output to there instead
For me it started showing up when I commented the Debug check
// if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
// }
I don't know why this is working because the build varient is selected to debug only.
for reporting my Application Crashes use Acra library via Android Studio Gradle Dependencies in this form :
dependencies {
compile 'ch.acra:acra:4.6.2'
}
Now in Bebug version it work and return crash report goodly but after export Release version of application not work and return this error in logcat :
Not adding buildConfig to log. Class Not found : " + className + ". Please configure 'buildConfigClass' in your ACRA config
Then i use acra-4-6-2.jar file instead dependencies but not work still!
Too before saw this link but was not helpful fore me.
With thanks for your attention
It sounds like you are Proguardng your app on release but have not added the relevant ACRA classes to your Proguard config.
See https://github.com/ACRA/acra/wiki/ProGuard
None of the other answers actually provided the fix.
To fix this issue, assign your BuildConfig.class to the buildConfigClass field on your ReportsCrashes annotation declaration.
#ReportsCrashes(
buildConfigClass = BuildConfig.class )
public class YourApplication extends Application { ... }
If you are using so called "dynamic" configuration you are probably having "empty" annotation like #ReportsCrashes().
In that case it turns out that ACRA does not create proper default config. The solution is simple: just add some fake property there like:
#ReportsCrashes(formUri = "placeholder")
which you will later override in the dynamic config...