Could not find a package configuration file provided by "openssl" - flutter

I'm trying to use OpenSSL with Flutter using dart:ffi, but when i run the project on Ubuntu 20.04 the error message as below comes out. I tested the project on Windows 10 and it worked.
Project repository
CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(flutter_openssl_crypto)
find_package(openssl REQUIRED CONFIG)
add_library(${PROJECT_NAME} SHARED empty.c)
target_link_libraries(${PROJECT_NAME} PRIVATE openssl::crypto)
Error
CMakeLists.txt:6 (find_package):
Could not find a package configuration file provided by "openssl" with any
of the following names:
opensslConfig.cmake
openssl-config.cmake
Add the installation prefix of "openssl" to CMAKE_PREFIX_PATH or set
"openssl_DIR" to a directory containing one of the above files. If
"openssl" provides a separate development package or SDK, be sure it has
been installed.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 5.3s
Exception: Gradle task assembleDebug failed with exit code 1
How can i run the project on Ubuntu?

I found the problem.
I had installed Android Studio and Flutter SDK for Ubuntu software, that's the problem.
When I reinstalled both from the official websites, the project work's.

Related

Build Failed with Minecraft Forge Gradle with VSCode

I am currently setting up my environment to create a Minecraft Mod using VSCode as this is my main editor at work, but I'm getting an error running the .\gradlew genVSCodeRun.
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':runtimeClasspathCopy'.
> Could not find net.minecraftforge:forge:1.16.5-36.2.34_mapped_official_1.16.5.
Searched in the following locations:
- file:/C:/Users/luism/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.16.5-36.2.34_mapped_official_1.16.5/forge-1.16.5-36.2.34_mapped_official_1.16.5.pom
- file:/C:/Users/luism/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.16.5-36.2.34_mapped_official_1.16.5/forge-1.16.5-36.2.34_mapped_official_1.16.5.jar
Required by:
project :
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 18s
I can see that the Gradle importing process is failing because I don't have those two files.
I saw in this thread that the solution is to run the gradle eclipse command, but the Build still fails with the same error. I have the 1.17 JDK as it is recommended in the Forge documentation and pathed it in the VS settings.json. I also downloaded the Forge MDK for 1.16.5 and executing commands in the correct unzipped location of the MDK.
Any ideas about what I'm doing wrong? Thanks!

Gradle Version in VSCode running Flutter app

I've install the VSCode, Android Studio, and Flutter in my windows. when I try to launch the android emulator (Pixel 4 API TiramisuPrivacySandbox) and Run the app ( default test app generated in VSCode - click counter) I get an error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:7.1.2.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom
https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom
Required by:
project :
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 31s
Exception: Gradle task assembleDebug failed with exit code 1
** in gradle-wrapper.properties file, the gradle version is 7.4
> distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
** in build.gradle file, the gradle version is 7.1.2
> dependencies {
> classpath 'com.android.tools.build:gradle:7.1.2'
> classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
> }`
** in web or windows devices, it runs without error.
Internet Issue ,Check your Internet Connection
if your internet is ok still having this issue then you need to change the internet connection (can use VPN) and try again hope it will work

Execution failed for task ':app:compileDebugKotlin'. Make sure Gradle is running on a JDK, not JRE

Installed Android Studio and flutter sdk (downloaded zip and unzip) on my mac. I created new flutter simple project on android studio app and ran it. Then, I got following error message.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
Error message
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v
I ran above commands in terminal and it is solved.

There is a error in android studio but same code working on flutlab.io

i tried to run a basic code in android studio. but it showing error. but the same code successfully compiled on flutlab.io
here is the error message.
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\HP\AndroidStudioProjects\helloapp\android\settings.gradle' (C:\Users\HP\.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Exception: Gradle task assembleDebug failed with exit code 1
i'm new to android studio. so please tell what's the wrong here.
Try to use JAVA SDK 15.
First remove your old JDK, and download & install Java JDK 15 from here.
Then, in Android Studio, change the path to the Java JDK so that it matches the latest install. Finally, restart Android Studio to apply the changes.

JDK installation not found by flutter starter app

I have cloned the flutter repo and installed the Android SDK command-line tools, setting them up in $HOME/Android. I then made flutter aware of the SDK installation by setting $ANDROID_HOME to $HOME/Android. Things seem to have worked out, with <path-to-flutter> doctor finding
Android SDK
my Java JDK 8 installation (openjdk-8-jdk package on Ubuntu 18.04), and
a connected Android phone with USB debugging
I am now trying to follow the test-run instructions for building a first app on the command line. <path-to-flutter> create myapp works and produces a myapp directory. I then try to run the resulting starter app:
cd myapp
~/myapp$ ANDROID_HOME=~/Android JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 <path-to-flutter> run
This results in the following error:
Launching lib/main.dart on ONEPLUS A6013 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 11.0s
Exception: Gradle task assembleDebug failed with exit code 1
I have seen this issue discussed before, but none of those replies seem to address it (in my case, at least). You can see from the command that I am exporting the right $JAVA_HOME, and besides, running
./android/gradlew build
inside the myapp directory does work:
~/myapp$ ./android/gradlew build
> Task :buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 319ms
1 actionable task: 1 executed
So this seems to be specific to flutter itself somehow, rather than gradle.
It turns out this must have been a path issue. The Flutter starter app builds (and pops up on my device) after inserting the following snippet in a file sourced in my profile (my .bashrc):
# Java
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
# Android
export ANDROID_HOME=${HOME}/Android
export ANDROID_SDK_ROOT=${HOME}/Android
# Flutter
export FLUTTER_HOME=${HOME}/repos/flutter
PATH=${FLUTTER_HOME}/bin:$PATH; export PATH
you can do like this -->
sudo apt-get remove --auto-remove openjdk*
sudo apt-get install openjdk-8-jre
now goto to home and visible your hidden folder by pressing ctrl+h
Now open .bashrc or your .rc
paste these on last
export PATH="$PATH:/snap/bin/flutter/bin"
export PATH="$PATH:/usr/bin/java"
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
export ANDROID_SDK_ROOT=/home/<YOUR USER NAME>/Android/Sdk
then run
source ~/bashrc
flutter doctor -v