Tag Archives: Android

[Solved] Failed to bind properties under ‘spring.datasource.type‘ to java.lang.Class<javax.sql.DataSource>

In the springcloud project, the following error occurs when starting:

***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under ‘spring.datasource.type’ to java.lang.Class<javax.sql.DataSource>:
Property: spring.datasource.type
Value: com.zaxxer.hikari.HikariDataSource
Origin: “spring.datasource.type” from property source “bootstrapProperties-config/application/”
Reason: No converter found capable of converting from type [java.lang.String] to type [java.lang.Class<javax.sql.DataSource>]
Action:
Update your application’s configuration
Disconnected from the target VM, address: ‘127.0.0.1:63170’, transport: ‘socket’
Process finished with exit code 1

Solution: Add the following reference to the pom file

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>

Attach POM file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>cloud-plateform-parent</artifactId>
        <groupId>org.shr</groupId>
        <version>1.0.3.RELEASE</version>
    </parent>
    <artifactId>aiservice</artifactId>
    <description>Demo project for Spring Boot</description>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
        </dependency>
        <!-- http核心 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-all</artifactId>
            <version>1.12.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.17.3</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.13</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-consul-all</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java-util</artifactId>
            <version>3.17.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>5.3.14</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign-core</artifactId>
            <version>2.2.9.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.0.6</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-autoconfigure</artifactId>
            <version>2.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.3.14</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>


    </dependencies>
    <build>
        <finalName>shr-centralized-inspect-service</finalName>
        <!-- os system information plugin, protobuf-maven-plugin needs to get the system information to download the corresponding protobuf program -->
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.6.2</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.5.0</version>
                <configuration>
                    <pluginId>grpc-java</pluginId>
                    <protocArtifact>com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}</protocArtifact>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.2.0:exe:${os.detected.classifier}</pluginArtifact>
                    <!-- proto file directory -->
                    <protoSourceRoot>${project.basedir}/src/main/proto</protoSourceRoot>
                    <!-- Generated Java files directory -->
                    <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                    <clearOutputDirectory>false</clearOutputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

[Solved] weditor Plug-in Dump Hierarchy Error: Local server not started, start with $ python -m weditor

I had tried many solutions online. but they do not work. here is my working solution I found finally.

 

Solution:

1. First, make sure that ADB devices can query your device

2. Key solution: delete ATX on the mobile phone and re-execute python -m uiautomator2 init

3. Just in case, don’t directly execute the WebEditor. Be sure to execute python -m weditor

Then click Dump Hierarchy to synchronize the screen. Don’t use real-time, just use static.

How to Solve Unity Package Android Project Error

1. Background

Unity project has the following capabilities

1. It can run directly on Android phones

2. You can build an APK file and then install it on the mobile phone to run

3. It can be packaged into an Android project and run the project using Android studio

There may be no problem that 1 and 2 can be implemented normally, but an error will be reported when implementing the third method
the first error:

unity UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

 

the second error:

UnityEditor.BuildPlayerWindow Error

 

2. Precautions

1. There is no problem with the configuration of gradle environment, because it can be compiled normally

2. The package directory also has no Chinese name

3. There is no problem with the packaging configuration

 

3. Solutions

Exporting Android Studio project needs to be consistent with our project name of unity

For example: File-BuildSettins-PlayerSetting-Player-ProductName name and File-BuildSettins-Build file directory name consistent can be solved

[Solved] java.lang.UnsatisfiedLinkError: dlopen failed: /lib/arm64/libc++_shared.so not found

java.lang.UnsatisfiedLinkError: dlopen failed: /lib/arm64/libc++_shared.so not found

1. Error description

When using other so libraries, sometimes you may encounter libc++_shared.so library cannot be found:

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.niuba.demo-t5NvrZc62MoQOW2PzC1Rvw==/lib/arm64/libc++_shared.so" not found

 

2. Cause of error

The so library used depends on the libc++_shared.so library file

3. Solutions

Go to any ndk version directory in the ndk directory, there are various versions in the llvm-libc++\libs directory

For example:

ndk\23.1.7779620\sources\cxx-stl\llvm-libc++\libs

 

[Solved] open failed: ENOENT (No such file or directory)

open failed: ENOENT (No such file or directory)

1. Error description

The following error occurred while writing the file to sdcard:

open failed: ENOENT (No such file or directory)

2. Error analysis

At first, I thought I forgot to add read-write permission, which was checked.

Finally, when I think of android10 onwards, in addition to the dynamic application of permissions, you must add in the Application node of AndroidManifest.xml of the main application.

android:requestLegacyExternalStorage="true"

3. Solution

Add the following codes in the Application node of AndroidManifest.xml of the main application:

android:requestLegacyExternalStorage="true"

 

[Solved] Installation failed due to: ‘INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Package com.

1. No system signature is added

If you have not added the system signature, find the following codes at the header of the AndroidManifest.xml file and delete it:

android:sharedUserId="android.uid.system"

2. Added system signature

  1. Check whether there is any problem with the system signature itself or the joining method?
  2. If there is no problem with the system signature, there should already be an APK in the system, and the current APK should be added to the system uid. At this time, you should first delete the APK that exists in the system, and then reboot.
adb root
adb uninstall com.xxx.xxxx
adb reboot

[Solved] socket failed: EPERM (Operation not permitted)

Reason & Solution:

1. The network permission is not enabled
2 HTTP is not supported

Add network permissions to AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

If the error is still reported, add the following to the Application in the AndroidManifest.xml file

android:usesCleartextTraffic="true"

Reason: On Android 9.0 machines, http access is not supported by default, all network access must use https. of course Android has supported https in several earlier versions, except that http is not supported by default using https on 9.0.

If the above operation can not be solved, please uninstall the application first, and then run it again.

[Solved] E xx: xxxx:xx ERR thread 0x536753929472 setscheduler failed Operation not permitted

E xx: xxxx:xx ERR thread 0x536753929472 setscheduler failed Operation not permitted

The “setscheduler failed Operation not permitted” error occurred when setting the thread priority via sched_setscheduler.

int ret = sched_setscheduler(pthread_gettid_np((pthread_t)pHandle), SCHED_RR, &prio);

 

Solution:
add the following contents to the process startup parameters:

capabilities SYS_NICE

init.target.rc

service xxxxxx /system/vendor/bin/xxxxxx
    class core
    user system
    group camera input graphics
    disabled
    onrestart restart evs_driver
    onrestart restart qcarcam_hal
    capabilities SYS_NICE

[Solved] Android12 Download Error: The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

Android12 install reports an error the application could not be installed: install_ PARSE_ FAILED_ MANIFEST_ MALFORMED

Solution:

For apps with Android12 as the adaptation platform, all four components that contain an intent-filter need to declare the android:exported attribute, and if the intent-filter contains LAUNCHER, it is best to declare it as android:exported= “true”

For example:

 <activity android:name=".MainActivity"
           android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 </activity>

The four main components that use intent-filter can be viewed through the Merged Manifest in the manifest file

If you still get the error Installation failed due to: ‘-127’, try adding the following parameter to the manifest file

<permission-group android:name="${applicationId}.andpermission" />

 

[Solved] Flutter Error: No MediaQuery widget ancestor found.

Error reporting is shown in figure

Problem code

import 'package:flutter/material.dart';

void main() {
  runApp(SampleAppPage());
}

class SampleAppPage extends StatefulWidget {
  const SampleAppPage({Key?key}) : super(key: key);

  @override
  _SampleAppPageState createState() => _SampleAppPageState();
}

class _SampleAppPageState extends State<SampleAppPage>
    with SingleTickerProviderStateMixin {
  late AnimationController controller;
  late CurvedAnimation curve;

  @override
  void initState() {
    super.initState();
    controller = AnimationController(
      duration: const Duration(milliseconds: 2000),
      vsync: this,
    );
    curve = CurvedAnimation(
      parent: controller,
      curve: Curves.easeIn,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: GestureDetector(
          child: RotationTransition(
            turns: curve,
            child: const FlutterLogo(size: 200.0),
          ),
          onDoubleTap: () {
            if (controller.isCompleted) {
              controller.reverse();
            } else {
              controller.forward();
            }
          },
        ),
      ),
    );
  }
}

Reason: the root component of the fluent interface must be MaterialApp

Code after repair

import 'package:flutter/material.dart';

void main() {
  runApp(SampleApp());
}

class SampleApp extends StatelessWidget {
  // This widget is the root of your application.
  const SampleApp({Key?key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Sample App',
      home: SampleAppPage(),
    );
  }
}

class SampleAppPage extends StatefulWidget {
  const SampleAppPage({Key?key}) : super(key: key);

  @override
  _SampleAppPageState createState() => _SampleAppPageState();
}

class _SampleAppPageState extends State<SampleAppPage>
    with SingleTickerProviderStateMixin {
  late AnimationController controller;
  late CurvedAnimation curve;

  @override
  void initState() {
    super.initState();
    controller = AnimationController(
      duration: const Duration(milliseconds: 2000),
      vsync: this,
    );
    curve = CurvedAnimation(
      parent: controller,
      curve: Curves.easeIn,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: GestureDetector(
          child: RotationTransition(
            turns: curve,
            child: const FlutterLogo(size: 200.0),
          ),
          onDoubleTap: () {
            if (controller.isCompleted) {
              controller.reverse();
            } else {
              controller.forward();
            }
          },
        ),
      ),
    );
  }
}

 

[Solved] ERROR: Unknown host CPU architecture: arm64

ERROR: Unknown host CPU architecture: arm64

When compiling the android ndk project built on Android.mk, I found that the following error occurs on the m1 macbook pro

ERROR: Unknown host CPU architecture: arm64

Need to modify the ndk-build file in the ndk root directory (presumably because the m1 belongs to the arm architecture)

#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"
$DIR/build/ndk-build "$@"

Change to

#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"
arch -x86_64 /bin/bash $DIR/build/ndk-build "$@"

Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Today adb command to install apk,prompted the following error:.
Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Solution:
Method 1:
Change android:testOnly=”true” to android:testOnly=”false” in AndroidManifest.xml, or just remove it.
Method 2:
adb push .apk /tmp
adb shell pm install -t /tmp/.apk
Method 3:
adb install -t *.apk