mirror of
https://github.com/dstark5/Openlib.git
synced 2025-05-21 00:16:30 +08:00
Fixed gradle error on build
This commit is contained in:
@ -1,75 +1,49 @@
|
|||||||
def localProperties = new Properties()
|
plugins {
|
||||||
def localPropertiesFile = rootProject.file('local.properties')
|
id "com.android.application"
|
||||||
if (localPropertiesFile.exists()) {
|
id "kotlin-android"
|
||||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||||
localProperties.load(reader)
|
id "dev.flutter.flutter-gradle-plugin"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
|
||||||
if (flutterRoot == null) {
|
|
||||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
|
||||||
}
|
|
||||||
|
|
||||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
|
||||||
if (flutterVersionCode == null) {
|
|
||||||
flutterVersionCode = '1'
|
|
||||||
}
|
|
||||||
|
|
||||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
|
||||||
if (flutterVersionName == null) {
|
|
||||||
flutterVersionName = '1.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
|
||||||
apply plugin: 'kotlin-android'
|
|
||||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
|
||||||
|
|
||||||
|
|
||||||
def keystoreProperties = new Properties()
|
def keystoreProperties = new Properties()
|
||||||
def keystorePropertiesFile = rootProject.file('key.properties')
|
def keystorePropertiesFile = rootProject.file('key.properties')
|
||||||
if (keystorePropertiesFile.exists()) {
|
if (keystorePropertiesFile.exists()) {
|
||||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "com.app.openlib"
|
namespace = "com.app.openlib"
|
||||||
compileSdkVersion flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = '1.8'
|
jvmTarget = JavaVersion.VERSION_17
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "com.app.openlib"
|
applicationId = "com.app.openlib"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
|
minSdk = flutter.minSdkVersion
|
||||||
targetSdkVersion flutter.targetSdkVersion
|
targetSdk = flutter.targetSdkVersion
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode = flutter.versionCode
|
||||||
versionName flutterVersionName
|
versionName = flutter.versionName
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
release {
|
release {
|
||||||
keyAlias keystoreProperties['keyAlias']
|
keyAlias = keystoreProperties['keyAlias']
|
||||||
keyPassword keystoreProperties['keyPassword']
|
keyPassword = keystoreProperties['keyPassword']
|
||||||
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
|
storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
|
||||||
storePassword keystoreProperties['storePassword']
|
storePassword = keystoreProperties['storePassword']
|
||||||
v1SigningEnabled true
|
v1SigningEnabled = true
|
||||||
v2SigningEnabled true
|
v2SigningEnabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,18 +51,13 @@ android {
|
|||||||
release {
|
release {
|
||||||
// TODO: Add your own signing config for the release build.
|
// TODO: Add your own signing config for the release build.
|
||||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||||
// replace with "debug" when running on debug version
|
signingConfig = signingConfigs.release
|
||||||
signingConfig signingConfigs.release
|
minifyEnabled = false
|
||||||
minifyEnabled false
|
shrinkResources = false
|
||||||
shrinkResources false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
source '../..'
|
source = "../.."
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
||||||
}
|
}
|
@ -1,16 +1,3 @@
|
|||||||
buildscript {
|
|
||||||
ext.kotlin_version = '1.7.10'
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:7.3.0'
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
@ -18,14 +5,14 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.buildDir = '../build'
|
rootProject.buildDir = "../build"
|
||||||
subprojects {
|
subprojects {
|
||||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||||
}
|
}
|
||||||
subprojects {
|
subprojects {
|
||||||
project.evaluationDependsOn(':app')
|
project.evaluationDependsOn(":app")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("clean", Delete) {
|
tasks.register("clean", Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
|
@ -1,11 +1,25 @@
|
|||||||
include ':app'
|
pluginManagement {
|
||||||
|
def flutterSdkPath = {
|
||||||
|
def properties = new Properties()
|
||||||
|
file("local.properties").withInputStream { properties.load(it) }
|
||||||
|
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||||
|
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||||
|
return flutterSdkPath
|
||||||
|
}()
|
||||||
|
|
||||||
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
||||||
def properties = new Properties()
|
|
||||||
|
|
||||||
assert localPropertiesFile.exists()
|
repositories {
|
||||||
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
plugins {
|
||||||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||||
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
|
id "com.android.application" version "8.0.0" apply false
|
||||||
|
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
|
||||||
|
}
|
||||||
|
|
||||||
|
include ":app"
|
@ -35,7 +35,8 @@ class OpenLibrary extends TrendingBooksImpl {
|
|||||||
@override
|
@override
|
||||||
List<TrendingBookData> _parser(data) {
|
List<TrendingBookData> _parser(data) {
|
||||||
var document = parse(data.toString());
|
var document = parse(data.toString());
|
||||||
var bookList = document.querySelectorAll('li[class="searchResultItem"]');
|
var bookList =
|
||||||
|
document.querySelectorAll('li[class="searchResultItem sri--w-main"]');
|
||||||
List<TrendingBookData> trendingBooks = [];
|
List<TrendingBookData> trendingBooks = [];
|
||||||
for (var element in bookList) {
|
for (var element in bookList) {
|
||||||
if (element.querySelector('h3[class="booktitle"]')?.text != null &&
|
if (element.querySelector('h3[class="booktitle"]')?.text != null &&
|
||||||
|
@ -1,23 +1,67 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'dart:ui';
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
|
|
||||||
Future<void> shareBook(String title, String link, String path) async {
|
Future<void> shareBook(String title, String link, String path) async {
|
||||||
try {
|
try {
|
||||||
final url = Uri.parse(path);
|
String imagePath = await saveAndGetImagePath(path);
|
||||||
final response = await http.get(url);
|
|
||||||
final bytes = response.bodyBytes;
|
|
||||||
|
|
||||||
//temp
|
|
||||||
final temp = await getTemporaryDirectory();
|
|
||||||
final dest = '${temp.path}/image.jpg';
|
|
||||||
File(dest).writeAsBytes(bytes);
|
|
||||||
|
|
||||||
String message = 'Discover this amazing book: "$title"\nRead more : $link';
|
String message = 'Discover this amazing book: "$title"\nRead more : $link';
|
||||||
await Share.shareXFiles([XFile(dest)], text: message);
|
if (imagePath.isNotEmpty) {
|
||||||
|
await Share.shareXFiles([XFile(imagePath)], text: message);
|
||||||
|
} else {
|
||||||
|
await Share.share(message);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('Error sharing the book: $e');
|
debugPrint('Error sharing the book: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> saveAndGetImagePath(String url) async {
|
||||||
|
if (url != null && url.isNotEmpty) {
|
||||||
|
try {
|
||||||
|
final imageProvider = CachedNetworkImageProvider(url);
|
||||||
|
final imageStream = imageProvider.resolve(const ImageConfiguration());
|
||||||
|
String? localFilePath;
|
||||||
|
|
||||||
|
final Completer<ByteData> completer = Completer();
|
||||||
|
|
||||||
|
imageStream.addListener(
|
||||||
|
ImageStreamListener(
|
||||||
|
(ImageInfo info, bool _) async {
|
||||||
|
try {
|
||||||
|
final ByteData? byteData =
|
||||||
|
await info.image.toByteData(format: ImageByteFormat.png);
|
||||||
|
if (byteData != null) {
|
||||||
|
final Uint8List imageBytes = byteData.buffer.asUint8List();
|
||||||
|
final Directory tempDir = await getTemporaryDirectory();
|
||||||
|
final File imageFile = File('${tempDir.path}/image.jpg');
|
||||||
|
|
||||||
|
await imageFile.writeAsBytes(imageBytes);
|
||||||
|
localFilePath = imageFile.path;
|
||||||
|
completer.complete(byteData);
|
||||||
|
} else {
|
||||||
|
completer.completeError('Failed to get image bytes');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
completer.completeError(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (exception, stackTrace) {
|
||||||
|
completer.completeError('Failed to get image bytes');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await completer.future;
|
||||||
|
return localFilePath ?? "";
|
||||||
|
} catch (e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,11 +7,13 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
// Project imports:
|
// Project imports:
|
||||||
import 'package:openlib/ui/extensions.dart';
|
import 'package:openlib/ui/extensions.dart';
|
||||||
|
|
||||||
|
final secondaryColor = '#FB0101'.toColor();
|
||||||
|
|
||||||
ThemeData lightTheme = ThemeData(
|
ThemeData lightTheme = ThemeData(
|
||||||
primaryColor: Colors.white,
|
primaryColor: Colors.white,
|
||||||
colorScheme: ColorScheme.light(
|
colorScheme: ColorScheme.light(
|
||||||
primary: Colors.white,
|
primary: Colors.white,
|
||||||
secondary: '#FB0101'.toColor(),
|
secondary: secondaryColor,
|
||||||
tertiary: Colors.black,
|
tertiary: Colors.black,
|
||||||
tertiaryContainer: '#F2F2F2'.toColor(),
|
tertiaryContainer: '#F2F2F2'.toColor(),
|
||||||
),
|
),
|
||||||
@ -36,18 +38,20 @@ ThemeData lightTheme = ThemeData(
|
|||||||
fontFamily: GoogleFonts.nunito().fontFamily,
|
fontFamily: GoogleFonts.nunito().fontFamily,
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
textSelectionTheme: TextSelectionThemeData(
|
textSelectionTheme: TextSelectionThemeData(
|
||||||
selectionColor: '#FB0101'.toColor(),
|
selectionColor: secondaryColor,
|
||||||
selectionHandleColor: '#FB0101'.toColor(),
|
selectionHandleColor: secondaryColor,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
ThemeData darkTheme = ThemeData(
|
ThemeData darkTheme = ThemeData(
|
||||||
primaryColor: Colors.black,
|
primaryColor: Colors.black,
|
||||||
|
scaffoldBackgroundColor: Colors.black,
|
||||||
colorScheme: ColorScheme.dark(
|
colorScheme: ColorScheme.dark(
|
||||||
primary: Colors.black,
|
primary: Colors.black,
|
||||||
secondary: '#FB0101'.toColor(),
|
secondary: secondaryColor,
|
||||||
tertiary: Colors.white,
|
tertiary: Colors.white,
|
||||||
tertiaryContainer: '#2B2B2B'.toColor(),
|
tertiaryContainer: '#141414'.toColor(),
|
||||||
|
surface: Colors.black,
|
||||||
),
|
),
|
||||||
textTheme: TextTheme(
|
textTheme: TextTheme(
|
||||||
displayLarge: const TextStyle(
|
displayLarge: const TextStyle(
|
||||||
@ -71,7 +75,7 @@ ThemeData darkTheme = ThemeData(
|
|||||||
fontFamily: GoogleFonts.nunito().fontFamily,
|
fontFamily: GoogleFonts.nunito().fontFamily,
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
textSelectionTheme: TextSelectionThemeData(
|
textSelectionTheme: TextSelectionThemeData(
|
||||||
selectionColor: '#FB0101'.toColor(),
|
selectionColor: secondaryColor,
|
||||||
selectionHandleColor: '#FB0101'.toColor(),
|
selectionHandleColor: secondaryColor,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -358,14 +358,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.3"
|
version: "2.5.3"
|
||||||
flutter_share:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_share
|
|
||||||
sha256: ae12c1cea13b35926a109824ffac601531e40cb94ad53eeae58625eceb3eaaaa
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.0"
|
|
||||||
flutter_svg:
|
flutter_svg:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -66,7 +66,6 @@ dependencies:
|
|||||||
http: ^1.2.2
|
http: ^1.2.2
|
||||||
path: ^1.9.0
|
path: ^1.9.0
|
||||||
share_plus: ^10.1.0
|
share_plus: ^10.1.0
|
||||||
flutter_share: ^2.0.0
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
import_sorter: ^4.6.0
|
import_sorter: ^4.6.0
|
||||||
|
Reference in New Issue
Block a user