Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle config does not exist after Android Studio update. Project fails to build. #8927

Closed
apptrash opened this issue May 11, 2021 · 9 comments
Assignees
Labels

Comments

@apptrash
Copy link

After updating android studio, when building, the following message is shown:

Build file '/home/alex/Разработка/src/android-git/exoplayer/extensions/av1/build.gradle' line: 14

A problem occurred evaluating project ':exoplayer-extension-av1'.
> Could not read script '/home/alex/.gradle/daemon/exoplayer/common_library_config.gradle' as it does not exist.

I'm using ExoPlayer r2.12.1

Here is a project structure (among others):

cgc.launcher/settings.gradle
exoplayer/

Here is cgc.launcher/settings.gradle content:

include ':app'

gradle.ext.exoplayerRoot = '../exoplayer'
gradle.ext.exoplayerModulePrefix = 'exoplayer-'
apply from: new File(gradle.ext.exoplayerRoot, 'core_settings.gradle')

Also, from cgc.launcher/app/build.gradle:

...
implementation project(':exoplayer-library')
implementation project(':exoplayer-extension-ffmpeg')
implementation project(':exoplayer-extension-rtmp')
implementation project(':exoplayer-extension-okhttp')
...

Here is information about Android Studio:

Android Studio 4.2
Build #AI-202.7660.26.42.7322048, built on April 29, 2021
Runtime version: 11.0.8+0-b944-P17168821 amd64
VM: OpenJDK 64-Bit Server VM by N/A
Linux 5.11.0-16-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 4
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin
Current Desktop: ubuntu:GNOME

I will provide more information if required. What can I do to fix the problem?

@apptrash
Copy link
Author

Rolled back the version to

Android Studio 4.1.3
Build #AI-201.8743.12.41.7199119, built on March 11, 2021
Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.11.0-16-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 2014M
Cores: 4
Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true
Current Desktop: ubuntu:GNOME

Everything is OK on this version

@alex3d
Copy link
Contributor

alex3d commented May 11, 2021

The problem is as of Android Studio 4.2 gradle.ext.exoplayerRoot should be set to an absolute path. This probably could be mentioned in exoplayer readme.

Android Studio 4.2 is bundled with JDK 11 instead of JDK 8 in previous versions, and see gradle/gradle#8286 (comment)

@Samrobbo Samrobbo self-assigned this May 13, 2021
@Samrobbo
Copy link
Contributor

Hi @apptrash, it looks like alex3d has given you a possible solution, did it work?

You could also try updating to the latest ExoPlayer release and see what effect that has.

@apptrash
Copy link
Author

@Samrobbo, hi! Yeah, it does help. But now everyone who involved in project should set this path manually

@Samrobbo
Copy link
Contributor

There may be an alternate way to do this, but I don't think it's specific to ExoPlayer. You might find some success asking a similar question on StackOverflow or in a gradle forum.

@Samrobbo Samrobbo changed the title Failed to build project after Android Studio update Gradle config does not exist after Android Studio update. Project fails to build. May 13, 2021
@apptrash
Copy link
Author

Okay, I'll ask a similar question and write here what I found out.

@apptrash
Copy link
Author

"${rootProject.projectDir}/../exoplayer" works fine for me

@S0und
Copy link

S0und commented May 13, 2021

To be more specific
in your settings.gradle

Change this:
gradle.ext.exoplayerRoot = '$rootDir/../../ExoPlayer'

to this:

gradle.ext.exoplayerRoot = "${rootProject.projectDir}/../ExoPlayer"

Obviously the initial path can be different, but the end of the day it has to correctly point to common_library_config.gradle which is in the root of the /ExoPlayer/ folder

ojw28 pushed a commit that referenced this issue May 14, 2021
Issue: #8927

#minor-release

PiperOrigin-RevId: 373752448
ojw28 pushed a commit that referenced this issue May 14, 2021
Issue: #8927

#minor-release

PiperOrigin-RevId: 373752448
@icbaker icbaker assigned icbaker and unassigned Samrobbo May 17, 2021
@icbaker
Copy link
Collaborator

icbaker commented May 17, 2021

After changing the README instructions above to require an absolute path, I took another look to see if we could remove that requirement.

I worked out the problem comes when constructing a File object from the exoplayerRoot string. Gradle says we can't call new File with a relative path, we have to use their Project.file method:
https://docs.gradle.org/current/userguide/working_with_files.html#sec:single_file_paths

And indeed I can use that to fix the problem by editing core_settings.gradle.

I've sent a change to make this fix - it will appear below when it's merged and should be included in 2.14.1 (but if people are depending on ExoPlayer locally they can of course apply the patch directly).

ojw28 pushed a commit that referenced this issue May 19, 2021
Gradle warns against passing a relative path to `new File(String)`:
https://docs.gradle.org/current/userguide/working_with_files.html#sec:single_file_paths

This change fixes all usages of `exoplayerRoot` to pass it to Gradle's
`Project.file()` first, which returns an absolute `File`.

To reproduce the problem in Issue: #8927:
1. Checkout ExoPlayer git project, to e.g. `~/ExoPlayer/exoplayer-git`
2. Create a new Android Studio project in e.g. `~/AndroidStudioProjects/exoplayer-test`
3. Edit the new project's `settings.gradle` file as described in
   https://github.com/google/ExoPlayer/blob/release-v2/README.md
   using a relative path for `exoplayerRoot`:
   ```
   gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
   ```
4. In a shell:
   ```bash
   $ cd ~/AndroidStudioProjects/exoplayer-test/app
   $ ../gradlew build
   ```

(Step 4 is important, it seems running `./gradlew` from the project root
doesn't trigger the relative path problem)

This change fixes the problem, and also works with `exoplayerRoot` as a
`File` or `Path` object. `String`, `File` and `Path` all work with relative or
absolute paths:
```
gradle.ext.exoplayerRoot = '/home/ibaker/ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = new File('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = new File('../../ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('../../ExoPlayer/exoplayer-git')
```

Note: The Path versions above require importing `java.nio.file.Paths`
and changing the `apply from:` line in the project's settings.gradle
file to something like:
```
apply from: file(gradle.ext.exoplayerRoot.resolve('core_settings.gradle'))
```
It's assumed that a project wanting to pass a `Path` will make these
changes.

Issue: #8927
PiperOrigin-RevId: 374421627
ojw28 pushed a commit that referenced this issue Jun 10, 2021
Gradle warns against passing a relative path to `new File(String)`:
https://docs.gradle.org/current/userguide/working_with_files.html#sec:single_file_paths

This change fixes all usages of `exoplayerRoot` to pass it to Gradle's
`Project.file()` first, which returns an absolute `File`.

To reproduce the problem in Issue: #8927:
1. Checkout ExoPlayer git project, to e.g. `~/ExoPlayer/exoplayer-git`
2. Create a new Android Studio project in e.g. `~/AndroidStudioProjects/exoplayer-test`
3. Edit the new project's `settings.gradle` file as described in
   https://github.com/google/ExoPlayer/blob/release-v2/README.md
   using a relative path for `exoplayerRoot`:
   ```
   gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
   ```
4. In a shell:
   ```bash
   $ cd ~/AndroidStudioProjects/exoplayer-test/app
   $ ../gradlew build
   ```

(Step 4 is important, it seems running `./gradlew` from the project root
doesn't trigger the relative path problem)

This change fixes the problem, and also works with `exoplayerRoot` as a
`File` or `Path` object. `String`, `File` and `Path` all work with relative or
absolute paths:
```
gradle.ext.exoplayerRoot = '/home/ibaker/ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = new File('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = new File('../../ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('../../ExoPlayer/exoplayer-git')
```

Note: The Path versions above require importing `java.nio.file.Paths`
and changing the `apply from:` line in the project's settings.gradle
file to something like:
```
apply from: file(gradle.ext.exoplayerRoot.resolve('core_settings.gradle'))
```
It's assumed that a project wanting to pass a `Path` will make these
changes.

Issue: #8927
PiperOrigin-RevId: 374421627
waltojac pushed a commit to waltojac/ExoPlayer that referenced this issue Jun 15, 2021
Gradle warns against passing a relative path to `new File(String)`:
https://docs.gradle.org/current/userguide/working_with_files.html#sec:single_file_paths

This change fixes all usages of `exoplayerRoot` to pass it to Gradle's
`Project.file()` first, which returns an absolute `File`.

To reproduce the problem in Issue: google#8927:
1. Checkout ExoPlayer git project, to e.g. `~/ExoPlayer/exoplayer-git`
2. Create a new Android Studio project in e.g. `~/AndroidStudioProjects/exoplayer-test`
3. Edit the new project's `settings.gradle` file as described in
   https://github.com/google/ExoPlayer/blob/release-v2/README.md
   using a relative path for `exoplayerRoot`:
   ```
   gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
   ```
4. In a shell:
   ```bash
   $ cd ~/AndroidStudioProjects/exoplayer-test/app
   $ ../gradlew build
   ```

(Step 4 is important, it seems running `./gradlew` from the project root
doesn't trigger the relative path problem)

This change fixes the problem, and also works with `exoplayerRoot` as a
`File` or `Path` object. `String`, `File` and `Path` all work with relative or
absolute paths:
```
gradle.ext.exoplayerRoot = '/home/ibaker/ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = new File('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = new File('../../ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('../../ExoPlayer/exoplayer-git')
```

Note: The Path versions above require importing `java.nio.file.Paths`
and changing the `apply from:` line in the project's settings.gradle
file to something like:
```
apply from: file(gradle.ext.exoplayerRoot.resolve('core_settings.gradle'))
```
It's assumed that a project wanting to pass a `Path` will make these
changes.

Issue: google#8927
PiperOrigin-RevId: 374421627
@google google locked and limited conversation to collaborators Jul 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants