How to make ProgressiveMediaSource usable in ExoPlayer? Symbol not found - java

I am working on a project where I am trying to implement ExoPlayer to replace a VideoView. My issue is that I am getting this error: cannot find symbol class ProgressiveMediaSource
I have seen Why can't I locate ProgressiveMediaSource? and note that it is mentioned that ProgressiveMediaPlayer was added in ExoPlayer 2.10.0 - I am using 2.10.1 so version shouldn't be an issue. The other condition that was mentioned was having the Android project upgraded to AndroidX. I believe that I am only using AndroidX unless one of my dependencies is importing some support libraries (com.android.support).
The compiler throws an error on import:
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
If providing my gradle build script would help, let me know.

Error was due to human transcription error. I had typed progessive instead of progressive and never noticed until much later 😫
Lesson: if a symbol can't be found, make sure you spelled it correctly.

Related

Minecraft Forge 1.16.5 changes since 1.16.4 - compiling error

I am trying to learn Minecraft modding, and while following a tutorial for version 1.16.4, I found that their code did not work, and I presume this is a change to the API, since I am using 1.16.5.
I have looked at both official and unofficial API docs, but these did not provide me any insight. Could anyone point me to a better API reference, or better yet, to a VSCode extension that autocompletes for the most recent Forge API.
Here is the compile error when I ran ./gradlew.bat build with my minimal reproducible example (sorry about the code highlighting, I don't know how to fix it):
C:\Users\eric\Desktop\Programming\Java\Minecraft Mod 1\src\main\java\com\ericl5445\testmod1\core\init\ItemInit.java:1: error: package net.minecraftforge.item does not exist
import net.minecraftforge.item.Item;
^
C:\Users\eric\Desktop\Programming\Java\Minecraft Mod 1\src\main\java\com\ericl5445\testmod1\core\init\ItemInit.java:2: error: package net.minecraftforge.item does not exist
import net.minecraftforge.item.ItemGroup;
^
Here is my full code:
TestMod1.java
ItemInit.java
Any help would really be appreciated!
I do not have an api reference, however I have found that the ItemGroup class is not under net.minecraftforge.item. It is under the package net.minecraft.item.
Your IDE, usually Intellij Idea or Eclipse, should be able to tell you where these classes are located via a search functionality. In Eclipse, you can press Control/Command + Shift + T to bring up a search box with a list of all the classes in your workspace.
The Package You Need To import is net.minecraft.item.Item and net.minecraft.itemGroup,
Not net.minecraftforge.item.Item and net.minecraftforge.itemGroup

Android Studio not excluding a transitive dependency and complains about class conflict

Hi I'm working on an Android app and I need to use a library called Semantics3. The issue I'm having is that the Semantics3 library depends on a few different libraries one of which is org.json but Android Studio automatically includes its own unique version of org.json which causes various issues. I've tried a few things to work around this and I'll describe them below.
First, I just imported the Semantics3 library. All the code compiles but when code from the library runs to make a service call the app crashes. This is due to a "NoSuchMethod" error because Semantics3 makes use of a constructor from a class in org.json which the AS version doesn't include.
To get around this I made my own jar file of the Semantics3 code and add in the dependencies it needs on my own in Gradle. The app still crashes, though not because it can't find the constructor. In this case the error is due to an exception from org.json, specifically "org.json.JSONException: Value com.android.okhttp.internal.huc.HttpURLConnectionImpl of type java.lang.String cannot be converted to JSONObject". I couldn't figure out why this error was popping up so I decided to try out the Semantics3 library outside of Android and just made a simple Maven project. In the Maven project I can make service calls just fine with no issue, but if I add the jar file and dependencies on my own, I get the same error as in AS.
So I figure there's something missing in the source code on Github that I used to make the jar or something but that's beyond me to figure out, so I'm back at trying to just import the library. My final and current attempt involves trying to explicitly import the version of org.json that Semantics3 needs along with the Semantics3 library in Gradle. But when I bring in the Sematnics3 library I try to exclude the transitive dependency Semantics3 introduces to org.json. I've included the Gradle file for this attempt below.
// https://mvnrepository.com/artifact/com.semantics3/Sem3Java
implementation('com.semantics3:Sem3Java:1.2.4'){
exclude group:'org.json:json'
}
implementation 'org.json:json'
constraints {
implementation(group: 'org.json', name: 'json', version: '20190722') {
because 'Semantics3 requires version 20190722 of org.json, not the default AS version'
}
}
The issue is when I try to run the code with the above setup in Gradle I get an error saying there are duplicate class definitions contained in the Semantics3 library and org.json library. And yes there are certainly conflicts but I thought the exclude bit to the Semantics3 implementation would be enough to prevent that from happening. Did I make a mistake somewhere or am I misunderstanding or misusing the exclude? If it makes a difference it appears the Semantics3 library does hardcode the org.json library into its Jar file. I appreciate any help with this. Thank you.

How do I update all libraries, after Migrating to AndroidX? [duplicate]

This question already has an answer here:
Migrate resource files to Androidx
(1 answer)
Closed 3 years ago.
I've have recently migrated my app to AndroidX, blindly without knowing the ins and outs. As a result every time I run the project, it gives me a load of errors.
I have updated all my Gradle Dependencies and targetSDK to the most recent version code. I have also added the following to gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
But this has still made no difference.
Some of the following are examples of errors I am getting:
error: package android.support.annotation does not exist
error: package android.support.v7.widget does not exist
error: package RecyclerView does not exist
error: cannot find symbol class FragmentActivity
error: cannot find symbol class CardView
error: cannot find symbol class FragmentPagerAdapter
error: cannot find symbol class DialogFragment
I would just like to know I can get rid of these errors, as it is stopping me from running the project on my mobile device?
Here you can find the full class mapping.
In your case you have to change the imports:
error: package android.support.annotation does not exist
error: package android.support.v7.widget does not exist
Packages:
package androidx.annotation.*;
package androidx.appcompat.widget.*;
Classes:
android.support.v4.app.FragmentActivity androidx.fragment.app.FragmentActivity
android.support.v7.widget.CardView androidx.cardview.widget.CardView
android.support.v4.app.FragmentPagerAdapter androidx.fragment.app.FragmentPagerAdapter
android.support.v7.app.AppCompatDialogFragment androidx.appcompat.app.AppCompatDialogFragment
android.support.v7.widget.RecyclerView androidx.recyclerview.widget.RecyclerView
You seem to have everything set up correctly in your gradle file. The problem is that there are missing packages that have not yet been converted/migrated to AndroidX. Here's a little trick you can do:
Go to your app.gradle file and right-click anywhere.
Select Refactor on the menu that pops up.
In the sub-menu, select Migrate to AndroidX
Sit back and let Android studio migrate all your files.
To learn more, check this out.
I hope this helps. Merry coding!
In the Android Studio menu go to Refactor and select Migrate to AndroidX.
Rest the android studio will automatically do.
Other than this if you still find the error then you will have to manual perform certain task.
In the layout find all the old one and replace it like
android.support.v7.widget.CardView
with
androidx.cardview.widget.CardView
you will find the mapping related information here https://developer.android.com/jetpack/androidx/migrate/class-mappings
just find the old text by using Ctr+F and copy the replacement text
In the app build
implementation 'com.android.support:cardview-v7:28.0.0'
with
implementation 'androidx.cardview:cardview:1.0.0'
you will find mapping related information here https://developer.android.com/jetpack/androidx/migrate/artifact-mappings

Android compilation error after upgrading to 'com.google.android.gms:play-services-ads:18.1.0'

I am upgrading my play-services-ads library from version 12 to version 18.1:
dependencies {
api 'com.google.android.gms:play-services-ads:18.1.0'
}
The problem is that the compilation fails with this error:
.gradle/caches/transforms-1/files-1.1/play-services-ads-identifier-17.0.0.aar/75b3c9fbdc51199269673bd2fa8b6cfe/jars/classes.jar(com/google/android/gms/ads/identifier/AdvertisingIdClient.class): warning: Cannot find annotation method 'value()' in type 'GuardedBy': class file for javax.annotation.concurrent.GuardedBy not found
I took away all the usages for AdvertisingIdClient and left only the import, but the problem persists:
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
Is there anything I am doing wrong?
com.google.android.gms:play-services-ads:18.1.0 depends upon com.google.android.gms:play-services-ads-identifier:17.0.0, among other libraries.
Your error indicates that com.google.android.gms:play-services-ads-identifier:17.0.0 references javax.annotation.concurrent.GuardedBy. However, that class is not in the Android SDK. The POM file for com.google.android.gms:play-services-ads-identifier:17.0.0 should be referencing a library that has an implementation of that class, but it does not seem to.
One library that has an implementation of that class is com.google.code.findbugs:jsr305. Adding a dependency on com.google.code.findbugs:jsr305 for a recent version (e.g., 3.0.2) gave you that class, satisfying the compiler.
So, there appears to be a bug in the Play Services SDK packaging, which my workaround resolves. You might want to add a comment in your module's build.gradle file to consider removing the com.google.code.findbugs:jsr305 if a future update to com.google.android.gms:play-services-ads fixes this bug.

Possible reason for "Error:cannot generate view binders java.lang.NullPointerException"

I am using Android Studio for my Android projects. I faced an issue when builds crash with strange stacktrace, like this:
Error:Execution failed for task ':app:compileDevDebugJavaWithJavac'.
java.lang.RuntimeException: failure, see logs for details.
cannot generate view binders java.lang.NullPointerException
at android.databinding.tool.reflection.ModelMethod.isBoxingConversion(ModelMethod.java:155)
at android.databinding.tool.store.SetterStore.isBetterParameter(SetterStore.java:946)
at android.databinding.tool.store.SetterStore.getBestSetter(SetterStore.java:838)
and it was seemed that the databinding became broken as whole.
I made refactoring before and moved classes between packages.
In my case, I relied on Android Studio when renaming and moving classes between packages. But it didn't proceed correction for XMLs of layouts where were references on refactored classes in the type attribute of variable element in data.
So my previous type's value pointed to non existing files and build crashed.
It's simple mistake but it may take more time to find the source. Hope this would help someone.
For me, this started happening after updating Android Studio to version 3.5.2
To fix it, I downgraded Android Gradle Plugin
buildscript {
repositories {
//..........
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
//......
}
}
Make sure you import all classes you reference in xml bindings
I had code something like:
android:visible="#{obj instanceof A}"
I was getting that same error.
Turns out that class A was not imported on top. Adding <import type="com.company.A"> tag resolved the problem.
P.S. android:visible is a custom binding adapter I have.
If this question is still relevant. For me I figured that in my xml layout file I was including a class (not an instance of one) as a variable, i.e I had this code
<variable
name="Converters"
type="com.example.flexapp.utils.Converters" />
and it should have been
<import type="com.example.flexapp.utils.Converters"/>
since this was a class and not an object.
in my case my problem was in a LongClickListener that the method for this listener must have returned a boolean but my method returned void so when I added the correct return statement it worked just fine.
keep in mind if you use a data binding method you must return the correct value or else the error it throws is not helpful at all.
You may have stumbled upon this question after migrating to Android X. If that's the case, and you're positive your XML files are okay, but it's still not working, you should start looking at libraries that generate code.
Libraries that generate code cannot be easily converted by the Jettifyer. Some info here - https://blog.danlew.net/2018/11/14/the-reality-of-migrating-to-androidx/
In my case, I updated the obvious ones, but I still was missing something. So, what I did was go into my develop branch (that wasn't Android X), ran a build, and dug into the build folder to see all of the libraries that generated code. Once I did that, I was able to look at the suspects one by one until I found the dependency that was causing this issue. You could either update it, or, in my case, remove it, and this error was resolved. :)
The getter function for any instance that you refer from your xml file might not have been defined or the getter function might not have public access specifier.
Downgrading Android Gradle Plugin to 3.5.1 fixed the issue for me
I face this problem when I define variable like this (Android Studio don't warning anything)
<data>
<variable
name="onGlobalLayoutA"
type="ViewTreeObserver.OnGlobalLayoutListener"/>
<import type="android.view.ViewTreeObserver"/>
</data>
And I solve it by
<data>
<variable
name="onGlobalLayoutA"
type="android.view.ViewTreeObserver.OnGlobalLayoutListener"/>
</data>
Hope this would help someone.
In my case, the reason was that I used a type for a variable which is another module and that module is added as 'implementation ' in build script. Changing to 'api ' resolved the issue.
Clearly not the same issue as the one posted by atlascoder but I mention regardless, maybe someone gits this article with the same problem as I had.
As #hiddeneyes02 mentioned, this started happen when upgrading from Android Gradle Plugin from 3.5.1 to 3.5.2, this seems to be the bug:
https://issuetracker.google.com/issues/143778134
When I built the project with the command tool I got the same errors as in this post:
When building Android project with Android Gradle Plugin v. 3.5.2 my builds fail
In my case I wrote wrong the name of my view model variable inside the XML file. I had it named VProgressBar instead of vProgressBar:
android:visibility="#{fatherViewModel.vProgressBar}"

Categories

Resources