Popular New Releases in R
ggplot2
ggplot2 3.3.5
dplyr
dplyr 1.0.8
r4ds
First edition
rmarkdown
rmarkdown 2.13
devtools
devtools 2.4.3
Popular Libraries in R
by tidyverse r
5380 NOASSERTION
An implementation of the Grammar of Graphics in R
by qinwf r
4695
A curated list of awesome R packages, frameworks and software.
by rstudio r
4565 NOASSERTION
Easy interactive web applications with R
by tidyverse r
3990 NOASSERTION
dplyr: A grammar of data manipulation
by swirldev r
3684 GPL-3.0
:mortar_board: A collection of interactive courses for the swirl R package.
by johnmyleswhite r
3600
Code accompanying the book "Machine Learning for Hackers"
by twitter r
3348 GPL-3.0
Anomaly Detection with R
by hadley r
3060 NOASSERTION
R for data science: a book
by Rdatatable r
3002 MPL-2.0
R's data.table package extends data.frame:
Trending New libraries in R
by rmcelreath r
2223
Statistical Rethinking course winter 2022
by allisonhorst r
577 CC0-1.0
A great intro dataset for data exploration & visualization (alternative to iris).
by rmcelreath r
557
Statistical Rethinking Course Winter 2020/2021
by jiayiliujiayi r
539
"Every individual matters. Every individual has a role to play." This is a repository that archives the individual stories during the COVID19 pandemic. 备份普通人在疫情期间的记录。(持续翻译 & 更新中)
by TheEconomist r
484
Source code and data for The Economist's covid-19 excess deaths tracker
by mjskay r
427 GPL-3.0
Visualizations of distributions and uncertainty
by GuangchuangYu r
419
query stats of infected coronavirus cases
by facebookexperimental r
410 MIT
Robyn is an experimental, automated and open-sourced Marketing Mix Modeling (MMM) package from Facebook Marketing Science. It uses various machine learning techniques (Ridge regression with cross validation, multi-objective evolutionary algorithm for hyperparameter optimisation, gradient-based optimisation for budget allocation etc.) to define media channel efficiency and effectivity, explore adstock rates and saturation curves. It's built for granular datasets with many independent variables and therefore especially suitable for digital and direct response advertisers with rich dataset.
by RamiKrispin r
396 NOASSERTION
The coronavirus dataset
Top Authors in R
1
4919 Libraries
5115
2
312 Libraries
5768
3
302 Libraries
19147
4
173 Libraries
16
5
124 Libraries
2138
6
112 Libraries
24452
7
107 Libraries
693
8
104 Libraries
571
9
101 Libraries
151
10
98 Libraries
2338
1
4919 Libraries
5115
2
312 Libraries
5768
3
302 Libraries
19147
4
173 Libraries
16
5
124 Libraries
2138
6
112 Libraries
24452
7
107 Libraries
693
8
104 Libraries
571
9
101 Libraries
151
10
98 Libraries
2338
Trending Kits in R
No Trending Kits are available at this moment for R
Trending Discussions on R
Python/Docker ImportError: cannot import name 'json' from itsdangerous
Error: require() of ES modules is not supported when importing node-fetch
CentOS through a VM - no URLs in mirrorlist
Java, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
Error while downloading the requirements using pip install (setup command: use_2to3 is invalid.)
WARNING: Running pip as the 'root' user
android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify
How to open emulators in different windows at Android Studio (Bumblebee | 2021.1.1)?
How to install the Bumblebee 2021.1.1 Android Studio Patch?
Is there way in ggplot2 to place text on a curved path?
QUESTION
Python/Docker ImportError: cannot import name 'json' from itsdangerous
Asked 2022-Mar-31 at 12:49I am trying to get a Flask and Docker application to work but when I try and run it using my docker-compose up
command in my Visual Studio terminal, it gives me an ImportError called ImportError: cannot import name 'json' from itsdangerous
. I have tried to look for possible solutions to this problem but as of right now there are not many on here or anywhere else. The only two solutions I could find are to change the current installation of MarkupSafe and itsdangerous to a higher version: https://serverfault.com/questions/1094062/from-itsdangerous-import-json-as-json-importerror-cannot-import-name-json-fr and another one on GitHub that tells me to essentially change the MarkUpSafe and itsdangerous installation again https://github.com/aws/aws-sam-cli/issues/3661, I have also tried to make a virtual environment named veganetworkscriptenv
to install the packages but that has also failed as well. I am currently using Flask 2.0.0 and Docker 5.0.0 and the error occurs on line eight in vegamain.py.
Here is the full ImportError that I get when I try and run the program:
1veganetworkscript-backend-1 | Traceback (most recent call last):
2veganetworkscript-backend-1 | File "/app/vegamain.py", line 8, in <module>
3veganetworkscript-backend-1 | from flask import Flask
4veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/__init__.py", line 19, in <module>
5veganetworkscript-backend-1 | from . import json
6veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/json/__init__.py", line 15, in <module>
7veganetworkscript-backend-1 | from itsdangerous import json as _json
8veganetworkscript-backend-1 | ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.9/site-packages/itsdangerous/__init__.py)
9veganetworkscript-backend-1 exited with code 1
10
Here are my requirements.txt, vegamain.py, Dockerfile, and docker-compose.yml files:
requirements.txt:
1veganetworkscript-backend-1 | Traceback (most recent call last):
2veganetworkscript-backend-1 | File "/app/vegamain.py", line 8, in <module>
3veganetworkscript-backend-1 | from flask import Flask
4veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/__init__.py", line 19, in <module>
5veganetworkscript-backend-1 | from . import json
6veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/json/__init__.py", line 15, in <module>
7veganetworkscript-backend-1 | from itsdangerous import json as _json
8veganetworkscript-backend-1 | ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.9/site-packages/itsdangerous/__init__.py)
9veganetworkscript-backend-1 exited with code 1
10Flask==2.0.0
11Flask-SQLAlchemy==2.4.4
12SQLAlchemy==1.3.20
13Flask-Migrate==2.5.3
14Flask-Script==2.0.6
15Flask-Cors==3.0.9
16requests==2.25.0
17mysqlclient==2.0.1
18pika==1.1.0
19wolframalpha==4.3.0
20
vegamain.py:
1veganetworkscript-backend-1 | Traceback (most recent call last):
2veganetworkscript-backend-1 | File "/app/vegamain.py", line 8, in <module>
3veganetworkscript-backend-1 | from flask import Flask
4veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/__init__.py", line 19, in <module>
5veganetworkscript-backend-1 | from . import json
6veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/json/__init__.py", line 15, in <module>
7veganetworkscript-backend-1 | from itsdangerous import json as _json
8veganetworkscript-backend-1 | ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.9/site-packages/itsdangerous/__init__.py)
9veganetworkscript-backend-1 exited with code 1
10Flask==2.0.0
11Flask-SQLAlchemy==2.4.4
12SQLAlchemy==1.3.20
13Flask-Migrate==2.5.3
14Flask-Script==2.0.6
15Flask-Cors==3.0.9
16requests==2.25.0
17mysqlclient==2.0.1
18pika==1.1.0
19wolframalpha==4.3.0
20# Veganetwork (C) TetraSystemSolutions 2022
21# all rights are reserved.
22#
23# Author: Trevor R. Blanchard Feb-19-2022-Jul-30-2022
24#
25
26# get our imports in order first
27from flask import Flask # <-- error occurs here!!!
28
29# start the application through flask.
30app = Flask(__name__)
31
32# if set to true will return only a "Hello World" string.
33Debug = True
34
35# start a route to the index part of the app in flask.
36@app.route('/')
37def index():
38 if (Debug == True):
39 return 'Hello World!'
40 else:
41 pass
42
43# start the flask app here --->
44if __name__ == '__main__':
45 app.run(debug=True, host='0.0.0.0')
46
Dockerfile:
1veganetworkscript-backend-1 | Traceback (most recent call last):
2veganetworkscript-backend-1 | File "/app/vegamain.py", line 8, in <module>
3veganetworkscript-backend-1 | from flask import Flask
4veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/__init__.py", line 19, in <module>
5veganetworkscript-backend-1 | from . import json
6veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/json/__init__.py", line 15, in <module>
7veganetworkscript-backend-1 | from itsdangerous import json as _json
8veganetworkscript-backend-1 | ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.9/site-packages/itsdangerous/__init__.py)
9veganetworkscript-backend-1 exited with code 1
10Flask==2.0.0
11Flask-SQLAlchemy==2.4.4
12SQLAlchemy==1.3.20
13Flask-Migrate==2.5.3
14Flask-Script==2.0.6
15Flask-Cors==3.0.9
16requests==2.25.0
17mysqlclient==2.0.1
18pika==1.1.0
19wolframalpha==4.3.0
20# Veganetwork (C) TetraSystemSolutions 2022
21# all rights are reserved.
22#
23# Author: Trevor R. Blanchard Feb-19-2022-Jul-30-2022
24#
25
26# get our imports in order first
27from flask import Flask # <-- error occurs here!!!
28
29# start the application through flask.
30app = Flask(__name__)
31
32# if set to true will return only a "Hello World" string.
33Debug = True
34
35# start a route to the index part of the app in flask.
36@app.route('/')
37def index():
38 if (Debug == True):
39 return 'Hello World!'
40 else:
41 pass
42
43# start the flask app here --->
44if __name__ == '__main__':
45 app.run(debug=True, host='0.0.0.0')
46FROM python:3.9
47ENV PYTHONUNBUFFERED 1
48WORKDIR /app
49COPY requirements.txt /app/requirements.txt
50RUN pip install -r requirements.txt
51COPY . /app
52
docker-compose.yml:
1veganetworkscript-backend-1 | Traceback (most recent call last):
2veganetworkscript-backend-1 | File "/app/vegamain.py", line 8, in <module>
3veganetworkscript-backend-1 | from flask import Flask
4veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/__init__.py", line 19, in <module>
5veganetworkscript-backend-1 | from . import json
6veganetworkscript-backend-1 | File "/usr/local/lib/python3.9/site-packages/flask/json/__init__.py", line 15, in <module>
7veganetworkscript-backend-1 | from itsdangerous import json as _json
8veganetworkscript-backend-1 | ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.9/site-packages/itsdangerous/__init__.py)
9veganetworkscript-backend-1 exited with code 1
10Flask==2.0.0
11Flask-SQLAlchemy==2.4.4
12SQLAlchemy==1.3.20
13Flask-Migrate==2.5.3
14Flask-Script==2.0.6
15Flask-Cors==3.0.9
16requests==2.25.0
17mysqlclient==2.0.1
18pika==1.1.0
19wolframalpha==4.3.0
20# Veganetwork (C) TetraSystemSolutions 2022
21# all rights are reserved.
22#
23# Author: Trevor R. Blanchard Feb-19-2022-Jul-30-2022
24#
25
26# get our imports in order first
27from flask import Flask # <-- error occurs here!!!
28
29# start the application through flask.
30app = Flask(__name__)
31
32# if set to true will return only a "Hello World" string.
33Debug = True
34
35# start a route to the index part of the app in flask.
36@app.route('/')
37def index():
38 if (Debug == True):
39 return 'Hello World!'
40 else:
41 pass
42
43# start the flask app here --->
44if __name__ == '__main__':
45 app.run(debug=True, host='0.0.0.0')
46FROM python:3.9
47ENV PYTHONUNBUFFERED 1
48WORKDIR /app
49COPY requirements.txt /app/requirements.txt
50RUN pip install -r requirements.txt
51COPY . /app
52version: '3.8'
53services:
54 backend:
55 build:
56 context: .
57 dockerfile: Dockerfile
58 command: 'python vegamain.py'
59 ports:
60 - 8004:5000
61 volumes:
62 - .:/app
63 depends_on:
64 - db
65
66# queue:
67# build:
68# context: .
69# dockerfile: Dockerfile
70# command: 'python -u consumer.py'
71# depends_on:
72# - db
73
74 db:
75 image: mysql:5.7.22
76 restart: always
77 environment:
78 MYSQL_DATABASE: admin
79 MYSQL_USER: root
80 MYSQL_PASSWORD: root
81 MYSQL_ROOT_PASSWORD: root
82 volumes:
83 - .dbdata:/var/lib/mysql
84 ports:
85 - 33069:3306
86
How exactly can I fix this code? thank you!
ANSWER
Answered 2022-Feb-20 at 12:31I was facing the same issue while running docker containers with flask.
I downgraded Flask
to 1.1.4
and markupsafe
to 2.0.1
which solved my issue.
Check this for reference.
QUESTION
Error: require() of ES modules is not supported when importing node-fetch
Asked 2022-Mar-28 at 07:04I'm creating a program to analyze security camera streams and got stuck on the very first line. At the moment my .js file has nothing but the import of node-fetch and it gives me an error message. What am I doing wrong?
Running Ubuntu 20.04.2 LTS in Windows Subsystem for Linux.
Node version:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3
node-fetch package version:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
4
5node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
8
9keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
10
11dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
16
17dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
19
20maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
25
26dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
28
29published 3 days ago by endless <jimmy@warting.se>
30
esm package version:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
4
5node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
8
9keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
10
11dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
16
17dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
19
20maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
25
26dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
28
29published 3 days ago by endless <jimmy@warting.se>
30user@MYLLYTIN:~/CAMSERVER$ npm v esm
31
32esm@3.2.25 | MIT | deps: none | versions: 140
33Tomorrow's ECMAScript modules today!
34https://github.com/standard-things/esm#readme
35
36keywords: commonjs, ecmascript, export, import, modules, node, require
37
38dist
39.tarball: https://registry.npmjs.org/esm/-/esm-3.2.25.tgz
40.shasum: 342c18c29d56157688ba5ce31f8431fbb795cc10
41.integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
42.unpackedSize: 308.6 kB
43
44maintainers:
45- jdalton <john.david.dalton@gmail.com>
46
47dist-tags:
48latest: 3.2.25
49
50published over a year ago by jdalton <john.david.dalton@gmail.com>
51
Contents of the .js file (literally nothing but the import):
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
4
5node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
8
9keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
10
11dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
16
17dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
19
20maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
25
26dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
28
29published 3 days ago by endless <jimmy@warting.se>
30user@MYLLYTIN:~/CAMSERVER$ npm v esm
31
32esm@3.2.25 | MIT | deps: none | versions: 140
33Tomorrow's ECMAScript modules today!
34https://github.com/standard-things/esm#readme
35
36keywords: commonjs, ecmascript, export, import, modules, node, require
37
38dist
39.tarball: https://registry.npmjs.org/esm/-/esm-3.2.25.tgz
40.shasum: 342c18c29d56157688ba5ce31f8431fbb795cc10
41.integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
42.unpackedSize: 308.6 kB
43
44maintainers:
45- jdalton <john.david.dalton@gmail.com>
46
47dist-tags:
48latest: 3.2.25
49
50published over a year ago by jdalton <john.david.dalton@gmail.com>
51user@MYLLYTIN:~/CAMSERVER$ cat server.js
52import fetch from "node-fetch";
53
Result:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
4
5node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
8
9keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
10
11dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
16
17dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
19
20maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
25
26dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
28
29published 3 days ago by endless <jimmy@warting.se>
30user@MYLLYTIN:~/CAMSERVER$ npm v esm
31
32esm@3.2.25 | MIT | deps: none | versions: 140
33Tomorrow's ECMAScript modules today!
34https://github.com/standard-things/esm#readme
35
36keywords: commonjs, ecmascript, export, import, modules, node, require
37
38dist
39.tarball: https://registry.npmjs.org/esm/-/esm-3.2.25.tgz
40.shasum: 342c18c29d56157688ba5ce31f8431fbb795cc10
41.integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
42.unpackedSize: 308.6 kB
43
44maintainers:
45- jdalton <john.david.dalton@gmail.com>
46
47dist-tags:
48latest: 3.2.25
49
50published over a year ago by jdalton <john.david.dalton@gmail.com>
51user@MYLLYTIN:~/CAMSERVER$ cat server.js
52import fetch from "node-fetch";
53user@MYLLYTIN:~/CAMSERVER$ node -r esm server.js
54/home/user/CAMSERVER/node_modules/node-fetch/src/index.js:1
55Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/user/CAMSERVER/node_modules/node-fetch/src/index.js
56require() of ES modules is not supported.
57require() of /home/user/CAMSERVER/node_modules/node-fetch/src/index.js from /home/user/CAMSERVER/server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
58Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/user/CAMSERVER/node_modules/node-fetch/package.json.
59
60 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1089:13) {
61 code: 'ERR_REQUIRE_ESM'
62}
63user@MYLLYTIN:~/CAMSERVER$
64
ANSWER
Answered 2022-Feb-25 at 00:00Use ESM syntax, also use one of these methods before running the file.
- specify
"type":"module"
inpackage.json
- Or use this flag
--input-type=module
when running the file - Or use
.mjs
file extension
QUESTION
CentOS through a VM - no URLs in mirrorlist
Asked 2022-Mar-26 at 21:04I am trying to run a CentOS 8 server through VirtualBox (6.1.30) (Vagrant), which worked just fine yesterday for me, but today I tried running a sudo yum update
. I keep getting this error for some reason:
1[vagrant@192.168.38.4] ~ >> sudo yum update
2CentOS Linux 8 - AppStream 71 B/s | 38 B 00:00
3Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
4
I already tried to change the namespaces on /etc/resolve.conf
, remove the DNF folders and everything. On other computers, this works just fine, so I think the problem is with my host machine. I also tried to reset the network settings (I am on a Windows 10 host), without success either. It's not a DNS problem; it works just fine.
After I reinstalled Windows, I still have the same error in my VM.
File dnf.log:
1[vagrant@192.168.38.4] ~ >> sudo yum update
2CentOS Linux 8 - AppStream 71 B/s | 38 B 00:00
3Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
42022-01-31T15:28:03+0000 INFO --- logging initialized ---
52022-01-31T15:28:03+0000 DDEBUG timer: config: 2 ms
62022-01-31T15:28:03+0000 DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
72022-01-31T15:28:03+0000 DEBUG YUM version: 4.4.2
82022-01-31T15:28:03+0000 DDEBUG Command: yum update
92022-01-31T15:28:03+0000 DDEBUG Installroot: /
102022-01-31T15:28:03+0000 DDEBUG Releasever: 8
112022-01-31T15:28:03+0000 DEBUG cachedir: /var/cache/dnf
122022-01-31T15:28:03+0000 DDEBUG Base command: update
132022-01-31T15:28:03+0000 DDEBUG Extra commands: ['update']
142022-01-31T15:28:03+0000 DEBUG User-Agent: constructed: 'libdnf (CentOS Linux 8; generic; Linux.x86_64)'
152022-01-31T15:28:05+0000 DDEBUG Cleaning up.
162022-01-31T15:28:05+0000 SUBDEBUG
17Traceback (most recent call last):
18 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 574, in load
19 ret = self._repo.load()
20 File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 397, in load
21 return _repo.Repo_load(self)
22libdnf._error.Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
23
24During handling of the above exception, another exception occurred:
25
26Traceback (most recent call last):
27 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 67, in main
28 return _main(base, args, cli_class, option_parser_class)
29 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 106, in _main
30 return cli_run(cli, base)
31 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 122, in cli_run
32 cli.run()
33 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1050, in run
34 self._process_demands()
35 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 740, in _process_demands
36 load_available_repos=self.demands.available_repos)
37 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 394, in fill_sack
38 self._add_repo_to_sack(r)
39 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 137, in _add_repo_to_sack
40 repo.load()
41 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 581, in load
42 raise dnf.exceptions.RepoError(str(e))
43dnf.exceptions.RepoError: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
442022-01-31T15:28:05+0000 CRITICAL Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
45
ANSWER
Answered 2022-Mar-26 at 20:59Check out this article: CentOS Linux EOL
The below commands helped me:
1[vagrant@192.168.38.4] ~ >> sudo yum update
2CentOS Linux 8 - AppStream 71 B/s | 38 B 00:00
3Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
42022-01-31T15:28:03+0000 INFO --- logging initialized ---
52022-01-31T15:28:03+0000 DDEBUG timer: config: 2 ms
62022-01-31T15:28:03+0000 DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
72022-01-31T15:28:03+0000 DEBUG YUM version: 4.4.2
82022-01-31T15:28:03+0000 DDEBUG Command: yum update
92022-01-31T15:28:03+0000 DDEBUG Installroot: /
102022-01-31T15:28:03+0000 DDEBUG Releasever: 8
112022-01-31T15:28:03+0000 DEBUG cachedir: /var/cache/dnf
122022-01-31T15:28:03+0000 DDEBUG Base command: update
132022-01-31T15:28:03+0000 DDEBUG Extra commands: ['update']
142022-01-31T15:28:03+0000 DEBUG User-Agent: constructed: 'libdnf (CentOS Linux 8; generic; Linux.x86_64)'
152022-01-31T15:28:05+0000 DDEBUG Cleaning up.
162022-01-31T15:28:05+0000 SUBDEBUG
17Traceback (most recent call last):
18 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 574, in load
19 ret = self._repo.load()
20 File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 397, in load
21 return _repo.Repo_load(self)
22libdnf._error.Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
23
24During handling of the above exception, another exception occurred:
25
26Traceback (most recent call last):
27 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 67, in main
28 return _main(base, args, cli_class, option_parser_class)
29 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 106, in _main
30 return cli_run(cli, base)
31 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 122, in cli_run
32 cli.run()
33 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1050, in run
34 self._process_demands()
35 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 740, in _process_demands
36 load_available_repos=self.demands.available_repos)
37 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 394, in fill_sack
38 self._add_repo_to_sack(r)
39 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 137, in _add_repo_to_sack
40 repo.load()
41 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 581, in load
42 raise dnf.exceptions.RepoError(str(e))
43dnf.exceptions.RepoError: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
442022-01-31T15:28:05+0000 CRITICAL Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
45sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
46sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
47
Doing this will make DNF work, but you will no longer receive any updates.
To upgrade to CentOS 8 stream:
1[vagrant@192.168.38.4] ~ >> sudo yum update
2CentOS Linux 8 - AppStream 71 B/s | 38 B 00:00
3Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
42022-01-31T15:28:03+0000 INFO --- logging initialized ---
52022-01-31T15:28:03+0000 DDEBUG timer: config: 2 ms
62022-01-31T15:28:03+0000 DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
72022-01-31T15:28:03+0000 DEBUG YUM version: 4.4.2
82022-01-31T15:28:03+0000 DDEBUG Command: yum update
92022-01-31T15:28:03+0000 DDEBUG Installroot: /
102022-01-31T15:28:03+0000 DDEBUG Releasever: 8
112022-01-31T15:28:03+0000 DEBUG cachedir: /var/cache/dnf
122022-01-31T15:28:03+0000 DDEBUG Base command: update
132022-01-31T15:28:03+0000 DDEBUG Extra commands: ['update']
142022-01-31T15:28:03+0000 DEBUG User-Agent: constructed: 'libdnf (CentOS Linux 8; generic; Linux.x86_64)'
152022-01-31T15:28:05+0000 DDEBUG Cleaning up.
162022-01-31T15:28:05+0000 SUBDEBUG
17Traceback (most recent call last):
18 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 574, in load
19 ret = self._repo.load()
20 File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 397, in load
21 return _repo.Repo_load(self)
22libdnf._error.Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
23
24During handling of the above exception, another exception occurred:
25
26Traceback (most recent call last):
27 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 67, in main
28 return _main(base, args, cli_class, option_parser_class)
29 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 106, in _main
30 return cli_run(cli, base)
31 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 122, in cli_run
32 cli.run()
33 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1050, in run
34 self._process_demands()
35 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 740, in _process_demands
36 load_available_repos=self.demands.available_repos)
37 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 394, in fill_sack
38 self._add_repo_to_sack(r)
39 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 137, in _add_repo_to_sack
40 repo.load()
41 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 581, in load
42 raise dnf.exceptions.RepoError(str(e))
43dnf.exceptions.RepoError: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
442022-01-31T15:28:05+0000 CRITICAL Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
45sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
46sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
47sudo dnf install centos-release-stream -y
48sudo dnf swap centos-{linux,stream}-repos -y
49sudo dnf distro-sync -y
50
Optionally reboot if your kernel updated (not needed in containers).
QUESTION
Java, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
Asked 2022-Mar-26 at 15:23I have newly installed
1IntelliJ IDEA 2021.2 (Ultimate Edition)
2Build #IU-212.4746.92, built on July 27, 2021
3Licensed to XXXXXX
4Subscription is active until August 15, 2021.
5Runtime version: 11.0.11+9-b1504.13 amd64
6VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
7Linux 5.4.0-80-generic
8GC: G1 Young Generation, G1 Old Generation
9Memory: 2048M
10Cores: 3
11
12Kotlin: 212-1.5.10-release-IJ4746.92
13Current Desktop: X-Cinnamon
14
I cloned project I work with on other workstation without issues, but cannot start any class with main method and IDEA says:
1IntelliJ IDEA 2021.2 (Ultimate Edition)
2Build #IU-212.4746.92, built on July 27, 2021
3Licensed to XXXXXX
4Subscription is active until August 15, 2021.
5Runtime version: 11.0.11+9-b1504.13 amd64
6VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
7Linux 5.4.0-80-generic
8GC: G1 Young Generation, G1 Old Generation
9Memory: 2048M
10Cores: 3
11
12Kotlin: 212-1.5.10-release-IJ4746.92
13Current Desktop: X-Cinnamon
14Abnormal build process termination:
15/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=-5972351880001011455 -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US -Didea.paths.selector=IntelliJIdea2021.2 -Didea.home.path=/home/pm/idea-IU-212.4746.92 -Didea.config.path=/home/pm/.config/JetBrains/IntelliJIdea2021.2 -Didea.plugins.path=/home/pm/.local/share/JetBrains/IntelliJIdea2021.2 -Djps.log.dir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/log/build-log -Djps.fallback.jdk.home=/home/pm/idea-IU-212.4746.92/jbr -Djps.fallback.jdk.version=11.0.11 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server/rfg-survey-api_cc70fc05/_temp_ -Djps.backward.ref.index.builder=true -Djps.track.ap.dependencies=false --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -Dtmh.instrument.annotations=true -Dtmh.generate.line.numbers=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"/tmp/kotlin-idea-12426594439704512301-is-running\" -classpath /home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-launcher.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/lib/tools.jar org.jetbrains.jps.cmdline.Launcher /home/pm/idea-IU-212.4746.92/lib/slf4j.jar:/home/pm/idea-IU-212.4746.92/lib/idea_rt.jar:/home/pm/idea-IU-212.4746.92/lib/platform-api.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/forms_rt.jar:/home/pm/idea-IU-212.4746.92/lib/util.jar:/home/pm/idea-IU-212.4746.92/lib/annotations.jar:/home/pm/idea-IU-212.4746.92/lib/3rd-party.jar:/home/pm/idea-IU-212.4746.92/lib/kotlin-stdlib-jdk8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/jna-platform.jar:/home/pm/idea-IU-212.4746.92/lib/protobuf-java-3.15.8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders-6.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/javac2.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/aether-dependency-resolver.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-javac-extension-1.jar:/home/pm/idea-IU-212.4746.92/lib/jna.jar:/home/pm/idea-IU-212.4746.92/lib/jps-model.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-http-1.3.3.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/jasper-v2-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-reflect.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/ant/lib/ant-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/uiDesigner/lib/jps/java-guiForms-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-common.jar:/home/pm/idea-IU-212.4746.92/plugins/IntelliLang/lib/java-langInjection-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-constants-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/maven/lib/maven-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/gradle-java/lib/gradle-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/devkit/lib/devkit-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-common.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/javaee-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/webSphereIntegration/lib/jps/javaee-appServers-websphere-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/weblogicIntegration/lib/jps/javaee-appServers-weblogic-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/JPA/lib/jps/javaee-jpa-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-compilerPatch.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-jps-common.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-common.jar org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 34781 9f0681bb-da2a-48db-8344-900ddeb29804 /home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server
16Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
17Error: Could not create the Java Virtual Machine.
18Error: A fatal exception has occurred. Program will exit.
19
I found other comment to check Lombok works and I see it is fine.
How to fix the problem?
ANSWER
Answered 2021-Jul-28 at 07:22You are running the project via Java 1.8 and add the --add-opens
option to the runner. However Java 1.8 does not support it.
So, the first option is to use Java 11 to run the project, as Java 11 can recognize this VM option.
Another solution is to find a place where --add-opens
is added and remove it.
Check Run configuration in IntelliJ IDEA (VM options field) and Maven/Gradle configuration files for argLine
(Maven) and jvmArgs
(Gradle)
QUESTION
Error while downloading the requirements using pip install (setup command: use_2to3 is invalid.)
Asked 2022-Mar-05 at 07:13version pip 21.2.4 python 3.6
The command:
1pip install -r requirments.txt
2
The content of my requirements.txt
:
1pip install -r requirments.txt
2mongoengine==0.19.1
3numpy==1.16.2
4pylint
5pandas==1.1.5
6fawkes
7
The command is failing with this error
1pip install -r requirments.txt
2mongoengine==0.19.1
3numpy==1.16.2
4pylint
5pandas==1.1.5
6fawkes
7ERROR: Command errored out with exit status 1:
8 command: /Users/*/Desktop/ml/*/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"'; __file__='"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-pip-egg-info-97994d6e
9 cwd: /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/
10 Complete output (1 lines):
11 error in mongoengine setup command: use_2to3 is invalid.
12 ----------------------------------------
13WARNING: Discarding https://*/pypi/packages/mongoengine-0.19.1.tar.gz#md5=68e613009f6466239158821a102ac084 (from https://*/pypi/simple/mongoengine/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
14ERROR: Could not find a version that satisfies the requirement mongoengine==0.19.1 (from versions: 0.15.0, 0.19.1)
15ERROR: No matching distribution found for mongoengine==0.19.1
16
ANSWER
Answered 2021-Nov-19 at 13:30It looks like setuptools>=58
breaks support for use_2to3
:
So you should update setuptools
to setuptools<58
or avoid using packages with use_2to3
in the setup parameters.
I was having the same problem, pip==19.3.1
QUESTION
WARNING: Running pip as the 'root' user
Asked 2022-Feb-24 at 01:59I am making simple image of my python Django app in Docker. But at the end of the building container it throws next warning (I am building it on Ubuntu 20.04):
1WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead
2
Why does it throw this warning if I am installing Python requirements inside my image? I am building my image using:
1WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead
2sudo docker build -t my_app:1 .
3
Should I be worried about warning that pip throws, because I know it can break my system?
Here is my Dockerfile:
1WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead
2sudo docker build -t my_app:1 .
3FROM python:3.8-slim-buster
4
5WORKDIR /app
6
7COPY requirements.txt requirements.txt
8
9RUN pip install -r requirements.txt
10
11COPY . .
12
13CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
14
ANSWER
Answered 2021-Aug-29 at 08:12The way your container is built doesn't add a user, so everything is done as root.
You could create a user and install to that users's home directory by doing something like this;
1WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead
2sudo docker build -t my_app:1 .
3FROM python:3.8-slim-buster
4
5WORKDIR /app
6
7COPY requirements.txt requirements.txt
8
9RUN pip install -r requirements.txt
10
11COPY . .
12
13CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
14FROM python:3.8.3-alpine
15
16RUN pip install --upgrade pip
17
18RUN adduser -D myuser
19USER myuser
20WORKDIR /home/myuser
21
22COPY --chown=myuser:myuser requirements.txt requirements.txt
23RUN pip install --user -r requirements.txt
24
25ENV PATH="/home/myuser/.local/bin:${PATH}"
26
27COPY --chown=myuser:myuser . .
28
29CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
30
QUESTION
android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify
Asked 2022-Feb-23 at 14:13After upgrading to android 12, the application is not compiling. It shows
"Manifest merger failed with multiple errors, see logs"
Error showing in Merged manifest:
Merging Errors: Error: android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for
android:exported
when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. main manifest (this file)
I have set all the activity with android:exported="false"
. But it is still showing this issue.
My manifest file:
1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:tools="http://schemas.android.com/tools"
4 package="eu.siacs.conversations">
5
6 <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />
7
8 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10 <uses-permission android:name="android.permission.READ_CONTACTS" />
11 <uses-permission android:name="android.permission.READ_PROFILE" />
12 <uses-permission
13 android:name="android.permission.READ_PHONE_STATE"
14 android:maxSdkVersion="22" />
15 <uses-permission android:name="android.permission.INTERNET" />
16 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17 <uses-permission android:name="android.permission.WAKE_LOCK" />
18 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
19 <uses-permission android:name="android.permission.VIBRATE" />
20 <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
21 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
22 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
23 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
24 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
25 <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
26
27 <uses-feature
28 android:name="android.hardware.location"
29 android:required="false" />
30 <uses-feature
31 android:name="android.hardware.location.gps"
32 android:required="false" />
33 <uses-feature
34 android:name="android.hardware.location.network"
35 android:required="false" />
36
37 <uses-permission android:name="android.permission.CAMERA" />
38 <uses-permission android:name="android.permission.RECORD_AUDIO" />
39 <uses-permission android:name="android.permission.BLUETOOTH" />
40 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
41 <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
42 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
43
44 <uses-feature
45 android:name="android.hardware.camera"
46 android:required="false" />
47 <uses-feature
48 android:name="android.hardware.camera.autofocus"
49 android:required="false" />
50 <uses-feature
51 android:name="android.hardware.microphone"
52 android:required="false" />
53
54 <application
55 android:name=".Application"
56 android:allowBackup="false"
57 android:allowClearUserData="true"
58 android:appCategory="social"
59 android:hardwareAccelerated="true"
60 android:icon="@mipmap/ic_app_launch"
61 android:label="@string/app_name"
62 android:largeHeap="true"
63 android:networkSecurityConfig="@xml/network_security_configuration"
64 android:requestLegacyExternalStorage="true"
65 android:roundIcon="@mipmap/ic_app_launch_round"
66 android:theme="@style/ConversationsTheme"
67 android:usesCleartextTraffic="true"
68 android:windowSoftInputMode="adjustPan|adjustResize"
69 tools:replace="android:label"
70 tools:targetApi="q">
71 <activity
72 android:name=".ui.search.GroupSearchActivity"
73 android:exported="true" />
74 <activity
75 android:name=".ui.profileUpdating.FavouritesActivity"
76 android:exported="true" />
77 <activity
78 android:name=".ui.profileUpdating.NameActivity"
79 android:exported="true" />
80 <activity
81 android:name=".ui.CompulsoryUpdateActivity"
82 android:exported="true" />
83 <activity android:name=".ui.payments.doPayment.DoPaymentActivity"
84 android:exported="true" />
85 <activity android:name=".ui.individualList.IndividualListActivity"
86 android:exported="true" />
87 <activity android:name=".ui.payments.setPayment.SetPaymentActivity"
88 android:exported="true" />
89 <activity android:name=".ui.login.otpActivity.OTPActivity"
90 android:exported="true" />
91 <activity android:name=".ui.login.loginActivity.LoginActivity"
92 android:exported="true" />
93
94 <service android:name=".services.XmppConnectionService" android:exported="true" />
95
96 <receiver android:name=".services.EventReceiver"
97 android:exported="true">
98 <intent-filter>
99 <action android:name="android.intent.action.BOOT_COMPLETED" />
100 <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
101 <action android:name="android.intent.action.ACTION_SHUTDOWN" />
102 <action android:name="android.media.RINGER_MODE_CHANGED" />
103 </intent-filter>
104 </receiver>
105
106 <activity
107 android:name=".ui.ShareLocationActivity"
108 android:label="@string/title_activity_share_location"
109 android:exported="true"/>
110 <activity
111 android:name=".ui.SearchActivity"
112 android:label="@string/search_messages"
113 android:exported="true" />
114 <activity
115 android:name=".ui.RecordingActivity"
116 android:configChanges="orientation|screenSize"
117 android:theme="@style/ConversationsTheme.Dialog"
118 android:exported="true" />
119 <activity
120 android:name=".ui.ShowLocationActivity"
121 android:label="@string/title_activity_show_location"
122 android:exported="true" />
123 <activity
124 android:name=".ui.SplashActivity"
125 android:theme="@style/SplashTheme"
126 android:exported="true">
127 <intent-filter>
128 <action android:name="android.intent.action.MAIN" />
129
130 <category android:name="android.intent.category.LAUNCHER" />
131 </intent-filter>
132 </activity>
133 <activity
134 android:name=".ui.ConversationsActivity"
135 android:label="@string/app_name"
136 android:launchMode="singleTask"
137 android:minWidth="300dp"
138 android:minHeight="300dp"
139 android:exported="true"
140 android:windowSoftInputMode="stateHidden" />
141 <activity
142 android:name=".ui.ScanActivity"
143 android:screenOrientation="portrait"
144 android:exported="true"
145 android:theme="@style/ConversationsTheme.FullScreen"
146 android:windowSoftInputMode="stateAlwaysHidden" />
147 <activity
148 android:name=".ui.UriHandlerActivity"
149 android:label="@string/app_name"
150 android:exported="true">
151 <intent-filter>
152 <action android:name="android.intent.action.VIEW" />
153
154 <category android:name="android.intent.category.DEFAULT" />
155 <category android:name="android.intent.category.BROWSABLE" />
156
157 <data android:scheme="xmpp" />
158 </intent-filter>
159 <intent-filter android:autoVerify="true">
160 <action android:name="android.intent.action.VIEW" />
161
162 <category android:name="android.intent.category.DEFAULT" />
163 <category android:name="android.intent.category.BROWSABLE" />
164
165 <data android:scheme="https" />
166 <data android:host="im.app.in" />
167 <data android:pathPrefix="/i/" />
168 <data android:pathPrefix="/j/" />
169 </intent-filter>
170 <intent-filter>
171 <action android:name="android.intent.action.SENDTO" />
172
173 <category android:name="android.intent.category.DEFAULT" />
174
175 <data android:scheme="imto" />
176 <data android:host="jabber" />
177 </intent-filter>
178 </activity>
179 <activity
180 android:name=".ui.StartConversationActivity"
181 android:label="@string/title_activity_start_conversation"
182 android:launchMode="singleTop"
183 android:exported="true">
184 <intent-filter>
185 <action android:name="android.intent.action.VIEW" />
186 </intent-filter>
187 </activity>
188 <activity
189 android:name=".ui.SettingsActivity"
190 android:label="@string/title_activity_settings"
191 android:exported="true">
192 <intent-filter>
193 <action android:name="android.intent.action.MAIN" />
194
195 <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
196 </intent-filter>
197 </activity>
198 <activity
199 android:name=".ui.ChooseContactActivity"
200 android:label="@string/title_activity_choose_contact"
201 android:exported="true" />
202 <activity
203 android:name=".ui.BlocklistActivity"
204 android:label="@string/title_activity_block_list"
205 android:exported="true"/>
206 <activity
207 android:name=".ui.ChangePasswordActivity"
208 android:label="@string/change_password_on_server"
209 android:exported="true"/>
210 <activity
211 android:name=".ui.ChooseAccountForProfilePictureActivity"
212 android:enabled="false"
213 android:label="@string/choose_account"
214 android:exported="true">
215 <intent-filter android:label="@string/set_profile_picture">
216 <action android:name="android.intent.action.ATTACH_DATA" />
217
218 <category android:name="android.intent.category.DEFAULT" />
219
220 <data android:mimeType="image/*" />
221 </intent-filter>
222 </activity>
223 <activity
224 android:name=".ui.ShareViaAccountActivity"
225 android:label="@string/title_activity_share_via_account"
226 android:launchMode="singleTop"
227 android:exported="true" />
228 <activity
229 android:name=".ui.EditAccountActivity"
230 android:launchMode="singleTop"
231 android:exported="true"
232 android:windowSoftInputMode="stateHidden|adjustResize" />
233 <activity
234 android:name=".ui.ConferenceDetailsActivity"
235 android:label="@string/action_muc_details"
236 android:exported="true"
237 android:windowSoftInputMode="stateHidden" />
238 <activity
239 android:name=".ui.ContactDetailsActivity"
240 android:exported="true"
241 android:windowSoftInputMode="stateHidden" />
242 <activity
243 android:name=".ui.PublishProfilePictureActivity"
244 android:label="@string/mgmt_account_publish_avatar"
245 android:exported="true"
246 android:windowSoftInputMode="stateHidden" />
247 <activity
248 android:name=".ui.PublishGroupChatProfilePictureActivity"
249 android:exported="true"
250 android:label="@string/group_chat_avatar" />
251 <activity
252 android:name=".ui.ShareWithActivity"
253 android:label="@string/app_name"
254 android:launchMode="singleTop"
255 android:exported="true">
256 <intent-filter>
257 <action android:name="android.intent.action.SEND" />
258 <action android:name="android.intent.action.SEND_MULTIPLE" />
259
260 <category android:name="android.intent.category.DEFAULT" />
261
262 <data android:mimeType="text/plain" />
263 </intent-filter>
264 <intent-filter>
265 <action android:name="android.intent.action.SEND" />
266 <action android:name="android.intent.action.SEND_MULTIPLE" />
267
268 <category android:name="android.intent.category.DEFAULT" />
269
270 <data android:mimeType="*/*" />
271 </intent-filter>
272
273 <!-- the value here needs to be the full class name; independent of the configured applicationId -->
274 <meta-data
275 android:name="android.service.chooser.chooser_target_service"
276 android:value="eu.siacs.conversations.services.ContactChooserTargetService" />
277 </activity>
278 <activity
279 android:name=".ui.TrustKeysActivity"
280 android:label="@string/trust_omemo_fingerprints"
281 android:exported="true"
282 android:windowSoftInputMode="stateAlwaysHidden" />
283 <activity
284 android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
285 android:exported="true"
286 android:theme="@style/Base.Theme.AppCompat" />
287 <activity android:name=".ui.MemorizingActivity"
288 android:exported="true" />
289 <activity
290 android:name=".ui.MediaBrowserActivity"
291 android:exported="true"
292 android:label="@string/media_browser" />
293
294 <service android:name=".services.ExportBackupService" android:exported="true"/>
295 <service android:name=".services.ImportBackupService" android:exported="true"/>
296 <service
297 android:name=".services.ContactChooserTargetService"
298 android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
299 android:exported="true">
300 <intent-filter>
301 <action android:name="android.service.chooser.ChooserTargetService" />
302 </intent-filter>
303 </service>
304 <service android:name=".services.CompulsoryUpdateService" android:exported="true"/>
305
306 <provider
307 android:name="androidx.core.content.FileProvider"
308 android:authorities="${applicationId}.files"
309 android:exported="false"
310 android:grantUriPermissions="true">
311 <meta-data
312 android:name="android.support.FILE_PROVIDER_PATHS"
313 android:resource="@xml/file_paths" />
314 </provider>
315 <provider
316 android:name=".services.BarcodeProvider"
317 android:authorities="${applicationId}.barcodes"
318 android:exported="false"
319 android:grantUriPermissions="true" />
320
321 <activity
322 android:name=".ui.ShortcutActivity"
323 android:label="@string/contact"
324 android:exported="true">
325 <intent-filter>
326 <action android:name="android.intent.action.CREATE_SHORTCUT" />
327 </intent-filter>
328 </activity>
329 <activity
330 android:name=".ui.MucUsersActivity"
331 android:exported="true"
332 android:label="@string/group_chat_members" />
333 <activity
334 android:name=".ui.ChannelDiscoveryActivity"
335 android:exported="true"
336 android:label="@string/discover_channels" />
337 <activity
338 android:name=".ui.RtpSessionActivity"
339 android:autoRemoveFromRecents="true"
340 android:exported="true"
341 android:launchMode="singleInstance"
342 android:supportsPictureInPicture="true" />
343 </application>
344
345</manifest>
346
My second manifest file:
1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:tools="http://schemas.android.com/tools"
4 package="eu.siacs.conversations">
5
6 <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />
7
8 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10 <uses-permission android:name="android.permission.READ_CONTACTS" />
11 <uses-permission android:name="android.permission.READ_PROFILE" />
12 <uses-permission
13 android:name="android.permission.READ_PHONE_STATE"
14 android:maxSdkVersion="22" />
15 <uses-permission android:name="android.permission.INTERNET" />
16 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17 <uses-permission android:name="android.permission.WAKE_LOCK" />
18 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
19 <uses-permission android:name="android.permission.VIBRATE" />
20 <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
21 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
22 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
23 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
24 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
25 <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
26
27 <uses-feature
28 android:name="android.hardware.location"
29 android:required="false" />
30 <uses-feature
31 android:name="android.hardware.location.gps"
32 android:required="false" />
33 <uses-feature
34 android:name="android.hardware.location.network"
35 android:required="false" />
36
37 <uses-permission android:name="android.permission.CAMERA" />
38 <uses-permission android:name="android.permission.RECORD_AUDIO" />
39 <uses-permission android:name="android.permission.BLUETOOTH" />
40 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
41 <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
42 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
43
44 <uses-feature
45 android:name="android.hardware.camera"
46 android:required="false" />
47 <uses-feature
48 android:name="android.hardware.camera.autofocus"
49 android:required="false" />
50 <uses-feature
51 android:name="android.hardware.microphone"
52 android:required="false" />
53
54 <application
55 android:name=".Application"
56 android:allowBackup="false"
57 android:allowClearUserData="true"
58 android:appCategory="social"
59 android:hardwareAccelerated="true"
60 android:icon="@mipmap/ic_app_launch"
61 android:label="@string/app_name"
62 android:largeHeap="true"
63 android:networkSecurityConfig="@xml/network_security_configuration"
64 android:requestLegacyExternalStorage="true"
65 android:roundIcon="@mipmap/ic_app_launch_round"
66 android:theme="@style/ConversationsTheme"
67 android:usesCleartextTraffic="true"
68 android:windowSoftInputMode="adjustPan|adjustResize"
69 tools:replace="android:label"
70 tools:targetApi="q">
71 <activity
72 android:name=".ui.search.GroupSearchActivity"
73 android:exported="true" />
74 <activity
75 android:name=".ui.profileUpdating.FavouritesActivity"
76 android:exported="true" />
77 <activity
78 android:name=".ui.profileUpdating.NameActivity"
79 android:exported="true" />
80 <activity
81 android:name=".ui.CompulsoryUpdateActivity"
82 android:exported="true" />
83 <activity android:name=".ui.payments.doPayment.DoPaymentActivity"
84 android:exported="true" />
85 <activity android:name=".ui.individualList.IndividualListActivity"
86 android:exported="true" />
87 <activity android:name=".ui.payments.setPayment.SetPaymentActivity"
88 android:exported="true" />
89 <activity android:name=".ui.login.otpActivity.OTPActivity"
90 android:exported="true" />
91 <activity android:name=".ui.login.loginActivity.LoginActivity"
92 android:exported="true" />
93
94 <service android:name=".services.XmppConnectionService" android:exported="true" />
95
96 <receiver android:name=".services.EventReceiver"
97 android:exported="true">
98 <intent-filter>
99 <action android:name="android.intent.action.BOOT_COMPLETED" />
100 <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
101 <action android:name="android.intent.action.ACTION_SHUTDOWN" />
102 <action android:name="android.media.RINGER_MODE_CHANGED" />
103 </intent-filter>
104 </receiver>
105
106 <activity
107 android:name=".ui.ShareLocationActivity"
108 android:label="@string/title_activity_share_location"
109 android:exported="true"/>
110 <activity
111 android:name=".ui.SearchActivity"
112 android:label="@string/search_messages"
113 android:exported="true" />
114 <activity
115 android:name=".ui.RecordingActivity"
116 android:configChanges="orientation|screenSize"
117 android:theme="@style/ConversationsTheme.Dialog"
118 android:exported="true" />
119 <activity
120 android:name=".ui.ShowLocationActivity"
121 android:label="@string/title_activity_show_location"
122 android:exported="true" />
123 <activity
124 android:name=".ui.SplashActivity"
125 android:theme="@style/SplashTheme"
126 android:exported="true">
127 <intent-filter>
128 <action android:name="android.intent.action.MAIN" />
129
130 <category android:name="android.intent.category.LAUNCHER" />
131 </intent-filter>
132 </activity>
133 <activity
134 android:name=".ui.ConversationsActivity"
135 android:label="@string/app_name"
136 android:launchMode="singleTask"
137 android:minWidth="300dp"
138 android:minHeight="300dp"
139 android:exported="true"
140 android:windowSoftInputMode="stateHidden" />
141 <activity
142 android:name=".ui.ScanActivity"
143 android:screenOrientation="portrait"
144 android:exported="true"
145 android:theme="@style/ConversationsTheme.FullScreen"
146 android:windowSoftInputMode="stateAlwaysHidden" />
147 <activity
148 android:name=".ui.UriHandlerActivity"
149 android:label="@string/app_name"
150 android:exported="true">
151 <intent-filter>
152 <action android:name="android.intent.action.VIEW" />
153
154 <category android:name="android.intent.category.DEFAULT" />
155 <category android:name="android.intent.category.BROWSABLE" />
156
157 <data android:scheme="xmpp" />
158 </intent-filter>
159 <intent-filter android:autoVerify="true">
160 <action android:name="android.intent.action.VIEW" />
161
162 <category android:name="android.intent.category.DEFAULT" />
163 <category android:name="android.intent.category.BROWSABLE" />
164
165 <data android:scheme="https" />
166 <data android:host="im.app.in" />
167 <data android:pathPrefix="/i/" />
168 <data android:pathPrefix="/j/" />
169 </intent-filter>
170 <intent-filter>
171 <action android:name="android.intent.action.SENDTO" />
172
173 <category android:name="android.intent.category.DEFAULT" />
174
175 <data android:scheme="imto" />
176 <data android:host="jabber" />
177 </intent-filter>
178 </activity>
179 <activity
180 android:name=".ui.StartConversationActivity"
181 android:label="@string/title_activity_start_conversation"
182 android:launchMode="singleTop"
183 android:exported="true">
184 <intent-filter>
185 <action android:name="android.intent.action.VIEW" />
186 </intent-filter>
187 </activity>
188 <activity
189 android:name=".ui.SettingsActivity"
190 android:label="@string/title_activity_settings"
191 android:exported="true">
192 <intent-filter>
193 <action android:name="android.intent.action.MAIN" />
194
195 <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
196 </intent-filter>
197 </activity>
198 <activity
199 android:name=".ui.ChooseContactActivity"
200 android:label="@string/title_activity_choose_contact"
201 android:exported="true" />
202 <activity
203 android:name=".ui.BlocklistActivity"
204 android:label="@string/title_activity_block_list"
205 android:exported="true"/>
206 <activity
207 android:name=".ui.ChangePasswordActivity"
208 android:label="@string/change_password_on_server"
209 android:exported="true"/>
210 <activity
211 android:name=".ui.ChooseAccountForProfilePictureActivity"
212 android:enabled="false"
213 android:label="@string/choose_account"
214 android:exported="true">
215 <intent-filter android:label="@string/set_profile_picture">
216 <action android:name="android.intent.action.ATTACH_DATA" />
217
218 <category android:name="android.intent.category.DEFAULT" />
219
220 <data android:mimeType="image/*" />
221 </intent-filter>
222 </activity>
223 <activity
224 android:name=".ui.ShareViaAccountActivity"
225 android:label="@string/title_activity_share_via_account"
226 android:launchMode="singleTop"
227 android:exported="true" />
228 <activity
229 android:name=".ui.EditAccountActivity"
230 android:launchMode="singleTop"
231 android:exported="true"
232 android:windowSoftInputMode="stateHidden|adjustResize" />
233 <activity
234 android:name=".ui.ConferenceDetailsActivity"
235 android:label="@string/action_muc_details"
236 android:exported="true"
237 android:windowSoftInputMode="stateHidden" />
238 <activity
239 android:name=".ui.ContactDetailsActivity"
240 android:exported="true"
241 android:windowSoftInputMode="stateHidden" />
242 <activity
243 android:name=".ui.PublishProfilePictureActivity"
244 android:label="@string/mgmt_account_publish_avatar"
245 android:exported="true"
246 android:windowSoftInputMode="stateHidden" />
247 <activity
248 android:name=".ui.PublishGroupChatProfilePictureActivity"
249 android:exported="true"
250 android:label="@string/group_chat_avatar" />
251 <activity
252 android:name=".ui.ShareWithActivity"
253 android:label="@string/app_name"
254 android:launchMode="singleTop"
255 android:exported="true">
256 <intent-filter>
257 <action android:name="android.intent.action.SEND" />
258 <action android:name="android.intent.action.SEND_MULTIPLE" />
259
260 <category android:name="android.intent.category.DEFAULT" />
261
262 <data android:mimeType="text/plain" />
263 </intent-filter>
264 <intent-filter>
265 <action android:name="android.intent.action.SEND" />
266 <action android:name="android.intent.action.SEND_MULTIPLE" />
267
268 <category android:name="android.intent.category.DEFAULT" />
269
270 <data android:mimeType="*/*" />
271 </intent-filter>
272
273 <!-- the value here needs to be the full class name; independent of the configured applicationId -->
274 <meta-data
275 android:name="android.service.chooser.chooser_target_service"
276 android:value="eu.siacs.conversations.services.ContactChooserTargetService" />
277 </activity>
278 <activity
279 android:name=".ui.TrustKeysActivity"
280 android:label="@string/trust_omemo_fingerprints"
281 android:exported="true"
282 android:windowSoftInputMode="stateAlwaysHidden" />
283 <activity
284 android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
285 android:exported="true"
286 android:theme="@style/Base.Theme.AppCompat" />
287 <activity android:name=".ui.MemorizingActivity"
288 android:exported="true" />
289 <activity
290 android:name=".ui.MediaBrowserActivity"
291 android:exported="true"
292 android:label="@string/media_browser" />
293
294 <service android:name=".services.ExportBackupService" android:exported="true"/>
295 <service android:name=".services.ImportBackupService" android:exported="true"/>
296 <service
297 android:name=".services.ContactChooserTargetService"
298 android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
299 android:exported="true">
300 <intent-filter>
301 <action android:name="android.service.chooser.ChooserTargetService" />
302 </intent-filter>
303 </service>
304 <service android:name=".services.CompulsoryUpdateService" android:exported="true"/>
305
306 <provider
307 android:name="androidx.core.content.FileProvider"
308 android:authorities="${applicationId}.files"
309 android:exported="false"
310 android:grantUriPermissions="true">
311 <meta-data
312 android:name="android.support.FILE_PROVIDER_PATHS"
313 android:resource="@xml/file_paths" />
314 </provider>
315 <provider
316 android:name=".services.BarcodeProvider"
317 android:authorities="${applicationId}.barcodes"
318 android:exported="false"
319 android:grantUriPermissions="true" />
320
321 <activity
322 android:name=".ui.ShortcutActivity"
323 android:label="@string/contact"
324 android:exported="true">
325 <intent-filter>
326 <action android:name="android.intent.action.CREATE_SHORTCUT" />
327 </intent-filter>
328 </activity>
329 <activity
330 android:name=".ui.MucUsersActivity"
331 android:exported="true"
332 android:label="@string/group_chat_members" />
333 <activity
334 android:name=".ui.ChannelDiscoveryActivity"
335 android:exported="true"
336 android:label="@string/discover_channels" />
337 <activity
338 android:name=".ui.RtpSessionActivity"
339 android:autoRemoveFromRecents="true"
340 android:exported="true"
341 android:launchMode="singleInstance"
342 android:supportsPictureInPicture="true" />
343 </application>
344
345</manifest>
346<?xml version="1.0" encoding="utf-8"?>
347<manifest xmlns:android="http://schemas.android.com/apk/res/android"
348 xmlns:tools="http://schemas.android.com/tools"
349 package="eu.siacs.conversations">
350
351 <application tools:ignore="GoogleAppIndexingWarning">
352 <activity
353 android:name=".ui.ManageAccountActivity"
354 android:label="@string/title_activity_manage_accounts"
355 android:launchMode="singleTask"
356 android:exported="true"/>
357 <activity
358 android:name=".ui.MagicCreateActivity"
359 android:label="@string/create_new_account"
360 android:launchMode="singleTask"
361 android:exported="true"/>
362 <activity
363 android:name=".ui.EasyOnboardingInviteActivity"
364 android:label="@string/invite_to_app"
365 android:launchMode="singleTask" />
366 <activity
367 android:name=".ui.ImportBackupActivity"
368 android:label="@string/restore_backup"
369 android:launchMode="singleTask"
370 android:exported="true">
371 <intent-filter>
372 <action android:name="android.intent.action.VIEW" />
373 <category android:name="android.intent.category.DEFAULT" />
374
375 <data android:mimeType="application/vnd.conversations.backup" />
376 <data android:scheme="content" />
377 </intent-filter>
378 <intent-filter>
379 <action android:name="android.intent.action.VIEW" />
380 <category android:name="android.intent.category.DEFAULT" />
381
382 <data android:mimeType="application/vnd.conversations.backup" />
383 <data android:scheme="file" />
384 </intent-filter>
385 <intent-filter>
386 <action android:name="android.intent.action.VIEW" />
387
388 <category android:name="android.intent.category.DEFAULT" />
389 <category android:name="android.intent.category.BROWSABLE" />
390
391 <data android:scheme="content" />
392 <data android:host="*" />
393 <data android:mimeType="*/*" />
394 <data android:pathPattern=".*\\.ceb" />
395 <data android:pathPattern=".*\\..*\\.ceb" />
396 <data android:pathPattern=".*\\..*\\..*\\.ceb" />
397 <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
398 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
399 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
400 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
401 </intent-filter>
402 <intent-filter>
403 <action android:name="android.intent.action.VIEW" />
404
405 <category android:name="android.intent.category.DEFAULT" />
406 <category android:name="android.intent.category.BROWSABLE" />
407
408 <data android:scheme="file" />
409 <data android:host="*" />
410 <data android:mimeType="*/*" />
411 <data android:pathPattern=".*\\.ceb" />
412 <data android:pathPattern=".*\\..*\\.ceb" />
413 <data android:pathPattern=".*\\..*\\..*\\.ceb" />
414 <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
415 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
416 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
417 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
418 </intent-filter>
419 </activity>
420 </application>
421</manifest>
422
423
My gradle file:
1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:tools="http://schemas.android.com/tools"
4 package="eu.siacs.conversations">
5
6 <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />
7
8 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10 <uses-permission android:name="android.permission.READ_CONTACTS" />
11 <uses-permission android:name="android.permission.READ_PROFILE" />
12 <uses-permission
13 android:name="android.permission.READ_PHONE_STATE"
14 android:maxSdkVersion="22" />
15 <uses-permission android:name="android.permission.INTERNET" />
16 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17 <uses-permission android:name="android.permission.WAKE_LOCK" />
18 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
19 <uses-permission android:name="android.permission.VIBRATE" />
20 <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
21 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
22 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
23 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
24 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
25 <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
26
27 <uses-feature
28 android:name="android.hardware.location"
29 android:required="false" />
30 <uses-feature
31 android:name="android.hardware.location.gps"
32 android:required="false" />
33 <uses-feature
34 android:name="android.hardware.location.network"
35 android:required="false" />
36
37 <uses-permission android:name="android.permission.CAMERA" />
38 <uses-permission android:name="android.permission.RECORD_AUDIO" />
39 <uses-permission android:name="android.permission.BLUETOOTH" />
40 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
41 <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
42 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
43
44 <uses-feature
45 android:name="android.hardware.camera"
46 android:required="false" />
47 <uses-feature
48 android:name="android.hardware.camera.autofocus"
49 android:required="false" />
50 <uses-feature
51 android:name="android.hardware.microphone"
52 android:required="false" />
53
54 <application
55 android:name=".Application"
56 android:allowBackup="false"
57 android:allowClearUserData="true"
58 android:appCategory="social"
59 android:hardwareAccelerated="true"
60 android:icon="@mipmap/ic_app_launch"
61 android:label="@string/app_name"
62 android:largeHeap="true"
63 android:networkSecurityConfig="@xml/network_security_configuration"
64 android:requestLegacyExternalStorage="true"
65 android:roundIcon="@mipmap/ic_app_launch_round"
66 android:theme="@style/ConversationsTheme"
67 android:usesCleartextTraffic="true"
68 android:windowSoftInputMode="adjustPan|adjustResize"
69 tools:replace="android:label"
70 tools:targetApi="q">
71 <activity
72 android:name=".ui.search.GroupSearchActivity"
73 android:exported="true" />
74 <activity
75 android:name=".ui.profileUpdating.FavouritesActivity"
76 android:exported="true" />
77 <activity
78 android:name=".ui.profileUpdating.NameActivity"
79 android:exported="true" />
80 <activity
81 android:name=".ui.CompulsoryUpdateActivity"
82 android:exported="true" />
83 <activity android:name=".ui.payments.doPayment.DoPaymentActivity"
84 android:exported="true" />
85 <activity android:name=".ui.individualList.IndividualListActivity"
86 android:exported="true" />
87 <activity android:name=".ui.payments.setPayment.SetPaymentActivity"
88 android:exported="true" />
89 <activity android:name=".ui.login.otpActivity.OTPActivity"
90 android:exported="true" />
91 <activity android:name=".ui.login.loginActivity.LoginActivity"
92 android:exported="true" />
93
94 <service android:name=".services.XmppConnectionService" android:exported="true" />
95
96 <receiver android:name=".services.EventReceiver"
97 android:exported="true">
98 <intent-filter>
99 <action android:name="android.intent.action.BOOT_COMPLETED" />
100 <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
101 <action android:name="android.intent.action.ACTION_SHUTDOWN" />
102 <action android:name="android.media.RINGER_MODE_CHANGED" />
103 </intent-filter>
104 </receiver>
105
106 <activity
107 android:name=".ui.ShareLocationActivity"
108 android:label="@string/title_activity_share_location"
109 android:exported="true"/>
110 <activity
111 android:name=".ui.SearchActivity"
112 android:label="@string/search_messages"
113 android:exported="true" />
114 <activity
115 android:name=".ui.RecordingActivity"
116 android:configChanges="orientation|screenSize"
117 android:theme="@style/ConversationsTheme.Dialog"
118 android:exported="true" />
119 <activity
120 android:name=".ui.ShowLocationActivity"
121 android:label="@string/title_activity_show_location"
122 android:exported="true" />
123 <activity
124 android:name=".ui.SplashActivity"
125 android:theme="@style/SplashTheme"
126 android:exported="true">
127 <intent-filter>
128 <action android:name="android.intent.action.MAIN" />
129
130 <category android:name="android.intent.category.LAUNCHER" />
131 </intent-filter>
132 </activity>
133 <activity
134 android:name=".ui.ConversationsActivity"
135 android:label="@string/app_name"
136 android:launchMode="singleTask"
137 android:minWidth="300dp"
138 android:minHeight="300dp"
139 android:exported="true"
140 android:windowSoftInputMode="stateHidden" />
141 <activity
142 android:name=".ui.ScanActivity"
143 android:screenOrientation="portrait"
144 android:exported="true"
145 android:theme="@style/ConversationsTheme.FullScreen"
146 android:windowSoftInputMode="stateAlwaysHidden" />
147 <activity
148 android:name=".ui.UriHandlerActivity"
149 android:label="@string/app_name"
150 android:exported="true">
151 <intent-filter>
152 <action android:name="android.intent.action.VIEW" />
153
154 <category android:name="android.intent.category.DEFAULT" />
155 <category android:name="android.intent.category.BROWSABLE" />
156
157 <data android:scheme="xmpp" />
158 </intent-filter>
159 <intent-filter android:autoVerify="true">
160 <action android:name="android.intent.action.VIEW" />
161
162 <category android:name="android.intent.category.DEFAULT" />
163 <category android:name="android.intent.category.BROWSABLE" />
164
165 <data android:scheme="https" />
166 <data android:host="im.app.in" />
167 <data android:pathPrefix="/i/" />
168 <data android:pathPrefix="/j/" />
169 </intent-filter>
170 <intent-filter>
171 <action android:name="android.intent.action.SENDTO" />
172
173 <category android:name="android.intent.category.DEFAULT" />
174
175 <data android:scheme="imto" />
176 <data android:host="jabber" />
177 </intent-filter>
178 </activity>
179 <activity
180 android:name=".ui.StartConversationActivity"
181 android:label="@string/title_activity_start_conversation"
182 android:launchMode="singleTop"
183 android:exported="true">
184 <intent-filter>
185 <action android:name="android.intent.action.VIEW" />
186 </intent-filter>
187 </activity>
188 <activity
189 android:name=".ui.SettingsActivity"
190 android:label="@string/title_activity_settings"
191 android:exported="true">
192 <intent-filter>
193 <action android:name="android.intent.action.MAIN" />
194
195 <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
196 </intent-filter>
197 </activity>
198 <activity
199 android:name=".ui.ChooseContactActivity"
200 android:label="@string/title_activity_choose_contact"
201 android:exported="true" />
202 <activity
203 android:name=".ui.BlocklistActivity"
204 android:label="@string/title_activity_block_list"
205 android:exported="true"/>
206 <activity
207 android:name=".ui.ChangePasswordActivity"
208 android:label="@string/change_password_on_server"
209 android:exported="true"/>
210 <activity
211 android:name=".ui.ChooseAccountForProfilePictureActivity"
212 android:enabled="false"
213 android:label="@string/choose_account"
214 android:exported="true">
215 <intent-filter android:label="@string/set_profile_picture">
216 <action android:name="android.intent.action.ATTACH_DATA" />
217
218 <category android:name="android.intent.category.DEFAULT" />
219
220 <data android:mimeType="image/*" />
221 </intent-filter>
222 </activity>
223 <activity
224 android:name=".ui.ShareViaAccountActivity"
225 android:label="@string/title_activity_share_via_account"
226 android:launchMode="singleTop"
227 android:exported="true" />
228 <activity
229 android:name=".ui.EditAccountActivity"
230 android:launchMode="singleTop"
231 android:exported="true"
232 android:windowSoftInputMode="stateHidden|adjustResize" />
233 <activity
234 android:name=".ui.ConferenceDetailsActivity"
235 android:label="@string/action_muc_details"
236 android:exported="true"
237 android:windowSoftInputMode="stateHidden" />
238 <activity
239 android:name=".ui.ContactDetailsActivity"
240 android:exported="true"
241 android:windowSoftInputMode="stateHidden" />
242 <activity
243 android:name=".ui.PublishProfilePictureActivity"
244 android:label="@string/mgmt_account_publish_avatar"
245 android:exported="true"
246 android:windowSoftInputMode="stateHidden" />
247 <activity
248 android:name=".ui.PublishGroupChatProfilePictureActivity"
249 android:exported="true"
250 android:label="@string/group_chat_avatar" />
251 <activity
252 android:name=".ui.ShareWithActivity"
253 android:label="@string/app_name"
254 android:launchMode="singleTop"
255 android:exported="true">
256 <intent-filter>
257 <action android:name="android.intent.action.SEND" />
258 <action android:name="android.intent.action.SEND_MULTIPLE" />
259
260 <category android:name="android.intent.category.DEFAULT" />
261
262 <data android:mimeType="text/plain" />
263 </intent-filter>
264 <intent-filter>
265 <action android:name="android.intent.action.SEND" />
266 <action android:name="android.intent.action.SEND_MULTIPLE" />
267
268 <category android:name="android.intent.category.DEFAULT" />
269
270 <data android:mimeType="*/*" />
271 </intent-filter>
272
273 <!-- the value here needs to be the full class name; independent of the configured applicationId -->
274 <meta-data
275 android:name="android.service.chooser.chooser_target_service"
276 android:value="eu.siacs.conversations.services.ContactChooserTargetService" />
277 </activity>
278 <activity
279 android:name=".ui.TrustKeysActivity"
280 android:label="@string/trust_omemo_fingerprints"
281 android:exported="true"
282 android:windowSoftInputMode="stateAlwaysHidden" />
283 <activity
284 android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
285 android:exported="true"
286 android:theme="@style/Base.Theme.AppCompat" />
287 <activity android:name=".ui.MemorizingActivity"
288 android:exported="true" />
289 <activity
290 android:name=".ui.MediaBrowserActivity"
291 android:exported="true"
292 android:label="@string/media_browser" />
293
294 <service android:name=".services.ExportBackupService" android:exported="true"/>
295 <service android:name=".services.ImportBackupService" android:exported="true"/>
296 <service
297 android:name=".services.ContactChooserTargetService"
298 android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
299 android:exported="true">
300 <intent-filter>
301 <action android:name="android.service.chooser.ChooserTargetService" />
302 </intent-filter>
303 </service>
304 <service android:name=".services.CompulsoryUpdateService" android:exported="true"/>
305
306 <provider
307 android:name="androidx.core.content.FileProvider"
308 android:authorities="${applicationId}.files"
309 android:exported="false"
310 android:grantUriPermissions="true">
311 <meta-data
312 android:name="android.support.FILE_PROVIDER_PATHS"
313 android:resource="@xml/file_paths" />
314 </provider>
315 <provider
316 android:name=".services.BarcodeProvider"
317 android:authorities="${applicationId}.barcodes"
318 android:exported="false"
319 android:grantUriPermissions="true" />
320
321 <activity
322 android:name=".ui.ShortcutActivity"
323 android:label="@string/contact"
324 android:exported="true">
325 <intent-filter>
326 <action android:name="android.intent.action.CREATE_SHORTCUT" />
327 </intent-filter>
328 </activity>
329 <activity
330 android:name=".ui.MucUsersActivity"
331 android:exported="true"
332 android:label="@string/group_chat_members" />
333 <activity
334 android:name=".ui.ChannelDiscoveryActivity"
335 android:exported="true"
336 android:label="@string/discover_channels" />
337 <activity
338 android:name=".ui.RtpSessionActivity"
339 android:autoRemoveFromRecents="true"
340 android:exported="true"
341 android:launchMode="singleInstance"
342 android:supportsPictureInPicture="true" />
343 </application>
344
345</manifest>
346<?xml version="1.0" encoding="utf-8"?>
347<manifest xmlns:android="http://schemas.android.com/apk/res/android"
348 xmlns:tools="http://schemas.android.com/tools"
349 package="eu.siacs.conversations">
350
351 <application tools:ignore="GoogleAppIndexingWarning">
352 <activity
353 android:name=".ui.ManageAccountActivity"
354 android:label="@string/title_activity_manage_accounts"
355 android:launchMode="singleTask"
356 android:exported="true"/>
357 <activity
358 android:name=".ui.MagicCreateActivity"
359 android:label="@string/create_new_account"
360 android:launchMode="singleTask"
361 android:exported="true"/>
362 <activity
363 android:name=".ui.EasyOnboardingInviteActivity"
364 android:label="@string/invite_to_app"
365 android:launchMode="singleTask" />
366 <activity
367 android:name=".ui.ImportBackupActivity"
368 android:label="@string/restore_backup"
369 android:launchMode="singleTask"
370 android:exported="true">
371 <intent-filter>
372 <action android:name="android.intent.action.VIEW" />
373 <category android:name="android.intent.category.DEFAULT" />
374
375 <data android:mimeType="application/vnd.conversations.backup" />
376 <data android:scheme="content" />
377 </intent-filter>
378 <intent-filter>
379 <action android:name="android.intent.action.VIEW" />
380 <category android:name="android.intent.category.DEFAULT" />
381
382 <data android:mimeType="application/vnd.conversations.backup" />
383 <data android:scheme="file" />
384 </intent-filter>
385 <intent-filter>
386 <action android:name="android.intent.action.VIEW" />
387
388 <category android:name="android.intent.category.DEFAULT" />
389 <category android:name="android.intent.category.BROWSABLE" />
390
391 <data android:scheme="content" />
392 <data android:host="*" />
393 <data android:mimeType="*/*" />
394 <data android:pathPattern=".*\\.ceb" />
395 <data android:pathPattern=".*\\..*\\.ceb" />
396 <data android:pathPattern=".*\\..*\\..*\\.ceb" />
397 <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
398 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
399 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
400 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
401 </intent-filter>
402 <intent-filter>
403 <action android:name="android.intent.action.VIEW" />
404
405 <category android:name="android.intent.category.DEFAULT" />
406 <category android:name="android.intent.category.BROWSABLE" />
407
408 <data android:scheme="file" />
409 <data android:host="*" />
410 <data android:mimeType="*/*" />
411 <data android:pathPattern=".*\\.ceb" />
412 <data android:pathPattern=".*\\..*\\.ceb" />
413 <data android:pathPattern=".*\\..*\\..*\\.ceb" />
414 <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
415 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
416 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
417 <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
418 </intent-filter>
419 </activity>
420 </application>
421</manifest>
422
423import com.android.build.OutputFile
424
425// Top-level build file where you can add configuration options common to all
426// sub-projects/modules.
427buildscript {
428 ext.kotlin_version = "1.5.21"
429 repositories {
430 google()
431 mavenCentral()
432 maven { url 'https://jitpack.io' }
433 gradlePluginPortal()
434 }
435 dependencies {
436 classpath 'com.android.tools.build:gradle:4.2.2'
437 classpath 'com.google.gms:google-services:4.3.8'
438 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
439 }
440}
441
442apply plugin: 'com.android.application'
443apply plugin: 'kotlin-android'
444apply plugin: 'kotlin-kapt'
445apply plugin: 'com.google.gms.google-services'
446
447repositories {
448 google()
449 mavenCentral()
450 jcenter()
451 maven { url 'https://jitpack.io' }
452}
453
454configurations {
455 conversationsFreeCompatImplementation
456}
457
458dependencies {
459 implementation 'androidx.viewpager:viewpager:1.0.0'
460 implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
461
462 implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
463
464 implementation 'org.sufficientlysecure:openpgp-api:10.0'
465 implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
466 implementation 'androidx.appcompat:appcompat:1.3.1'
467 implementation 'androidx.exifinterface:exifinterface:1.3.2'
468 implementation 'androidx.cardview:cardview:1.0.0'
469 implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
470 implementation 'androidx.emoji:emoji:1.1.0'
471 implementation 'com.google.android.material:material:1.4.0'
472 conversationsFreeCompatImplementation 'androidx.emoji:emoji-bundled:1.1.0'
473 implementation 'org.bouncycastle:bcmail-jdk15on:1.64'
474 //zxing stopped supporting Java 7 so we have to stick with 3.3.3
475 //https://github.com/zxing/zxing/issues/1170
476 implementation 'com.google.zxing:core:3.4.1'
477 implementation 'de.measite.minidns:minidns-hla:0.2.4'
478 implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
479 implementation 'org.whispersystems:signal-protocol-java:2.8.1'
480 implementation 'com.makeramen:roundedimageview:2.3.0'
481 implementation "com.wefika:flowlayout:0.4.1"
482 implementation 'net.ypresto.androidtranscoder:android-transcoder:0.3.0'
483 implementation 'org.jxmpp:jxmpp-jid:1.0.1'
484 implementation 'org.osmdroid:osmdroid-android:6.1.10'
485 implementation 'org.hsluv:hsluv:0.2'
486 implementation 'org.conscrypt:conscrypt-android:2.5.2'
487 implementation 'me.drakeet.support:toastcompat:1.1.0'
488 implementation "com.leinardi.android:speed-dial:3.2.0"
489
490 implementation "com.squareup.retrofit2:retrofit:2.9.0"
491 implementation "com.squareup.retrofit2:converter-gson:2.9.0"
492 implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
493 implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
494
495 implementation 'com.google.guava:guava:30.1.1-android'
496 implementation 'org.webrtc:google-webrtc:1.0.32006'
497
498 // Lifecycle Helper
499 implementation "androidx.activity:activity-ktx:1.3.0-rc02"
500 implementation "androidx.fragment:fragment-ktx:1.3.6"
501
502 //Navigation
503 implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
504 implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
505
506 //CardView
507 implementation "androidx.cardview:cardview:1.0.0"
508
509 //Country Code Picker
510 implementation 'com.hbb20:ccp:2.5.3'
511
512 //Firebase
513 implementation 'com.google.firebase:firebase-bom:28.3.0'
514 implementation 'com.google.firebase:firebase-auth-ktx:21.0.1'
515 implementation 'androidx.browser:browser:1.3.0'
516
517 //OTP view
518 implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.2'
519
520 //Retrofit
521 implementation 'com.squareup.retrofit2:retrofit:2.9.0'
522 implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
523
524 //Gson
525 implementation 'com.google.code.gson:gson:2.8.7'
526
527 //Multidex
528 implementation 'androidx.multidex:multidex:2.0.1'
529
530 //Round Image
531 implementation 'de.hdodenhof:circleimageview:3.1.0'
532
533 // Button with image and text
534 implementation 'com.github.Omega-R:OmegaCenterIconButton:0.0.4@aar'
535
536 //Razor pay
537 implementation 'com.razorpay:checkout:1.6.10'
538
539 //Mixpanel Tracking
540 implementation 'com.mixpanel.android:mixpanel-android:5.9.1'
541
542 //Loading screen
543 implementation 'com.wang.avi:library:2.1.3'
544
545 //Loading
546 implementation 'com.wang.avi:library:2.1.3'
547
548 //Form
549 implementation 'com.quickbirdstudios:surveykit:1.1.0'
550}
551
552ext {
553 travisBuild = System.getenv("TRAVIS") == "true"
554 preDexEnabled = System.getProperty("pre-dex", "true")
555 abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'x86_64': 3, 'arm64-v8a': 4]
556}
557
558android {
559 compileSdkVersion 31
560
561 defaultConfig {
562 minSdkVersion 24
563 targetSdkVersion 31
564 versionCode 44
565 versionName "2.0.4"
566 multiDexEnabled = true
567 archivesBaseName += "-$versionName"
568 applicationId "com.app.app"
569 resValue "string", "applicationId", applicationId
570 def appName = "app"
571 resValue "string", "app_name", appName
572 buildConfigField "String", "APP_NAME", "\"$appName\""
573 }
574
575 splits {
576 abi {
577 universalApk true
578 enable true
579 }
580 }
581
582 configurations {
583 compile.exclude group: 'org.jetbrains' , module:'annotations'
584 }
585
586 dataBinding {
587 enabled true
588 }
589
590 dexOptions {
591 // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
592 preDexLibraries = preDexEnabled && !travisBuild
593 jumboMode true
594 }
595
596 compileOptions {
597 sourceCompatibility JavaVersion.VERSION_1_8
598 targetCompatibility JavaVersion.VERSION_1_8
599 }
600
601 flavorDimensions("mode", "distribution", "emoji")
602
603 productFlavors {
604
605 conversations {
606 dimension "mode"
607 }
608 free {
609 dimension "distribution"
610 versionNameSuffix "+f"
611 }
612 compat {
613 dimension "emoji"
614 versionNameSuffix "c"
615 }
616 }
617
618 sourceSets {
619 conversationsFreeCompat {
620 java {
621 srcDir 'src/freeCompat/java'
622 srcDir 'src/conversationsFree/java'
623 }
624 }
625 }
626
627 buildTypes {
628 release {
629 shrinkResources true
630 minifyEnabled true
631 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
632 versionNameSuffix "r"
633 }
634 debug {
635 shrinkResources true
636 minifyEnabled true
637 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
638 versionNameSuffix "d"
639 }
640 }
641
642
643 if (new File("signing.properties").exists()) {
644 Properties props = new Properties()
645 props.load(new FileInputStream(file("signing.properties")))
646
647 signingConfigs {
648 release {
649 storeFile file(props['keystore'])
650 storePassword props['keystore.password']
651 keyAlias props['keystore.alias']
652 keyPassword props['keystore.password']
653 }
654 }
655 buildTypes.release.signingConfig = signingConfigs.release
656 }
657
658 lintOptions {
659 disable 'MissingTranslation', 'InvalidPackage','AppCompatResource'
660 }
661
662 subprojects {
663
664 afterEvaluate {
665 if (getPlugins().hasPlugin('android') ||
666 getPlugins().hasPlugin('android-library')) {
667
668 configure(android.lintOptions) {
669 disable 'AndroidGradlePluginVersion', 'MissingTranslation'
670 }
671 }
672
673 }
674 }
675
676 packagingOptions {
677 exclude 'META-INF/BCKEY.DSA'
678 exclude 'META-INF/BCKEY.SF'
679 }
680
681 android.applicationVariants.all { variant ->
682 variant.outputs.each { output ->
683 def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
684 if (baseAbiVersionCode != null) {
685 output.versionCodeOverride = (100 * variant.versionCode) + baseAbiVersionCode
686 }
687 }
688
689 }
690}
691
ANSWER
Answered 2021-Aug-04 at 09:18I'm not sure what you're using to code, but in order to set it in Android Studio, open the manifest of your project and under the "activity" section, put android:exported="true"(or false if that is what you prefer). I have attached an example.
QUESTION
How to open emulators in different windows at Android Studio (Bumblebee | 2021.1.1)?
Asked 2022-Feb-22 at 19:06I have two running emulators but they open together in different tabs and in one single window.
How to open them in two different window?
1Android Studio Bumblebee | 2021.1.1
2Build #AI-211.7628.21.2111.8092744, built on January 19, 2022
3Runtime version: 11.0.11+0-b60-7590822 amd64
4VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
5Linux 5.4.0-96-generic
6GC: G1 Young Generation, G1 Old Generation
7Memory: 3072M
8Cores: 12
9Registry: external.system.auto.import.disabled=true, debugger.watches.in.variables=false
10Non-Bundled Plugins: JUnit4-Parallel-Runner (1.5), com.intellij.javafx (1.0.3), com.intellij.marketplace (211.7628.36), com.atlassian.bitbucket.references (2021.1.195), com.thoughtworks.gauge (211.6693.111), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), com.developerphil.adbidea (1.6.4)
11Current Desktop: ubuntu:GNOME
12
ANSWER
Answered 2022-Feb-17 at 10:47File->Settings->Tools->Emulator, and uncheck Launch in a tool window Then they will open in their own stand alone windows again.
QUESTION
How to install the Bumblebee 2021.1.1 Android Studio Patch?
Asked 2022-Feb-10 at 19:28When I open Android Studio I receive a notification saying that an update is available:
1The latest stable release of Android Studio is now available for download.
2
3Android Studio Bumblebee | 2021.1.1 Patch 1 is a major new release and includes performance improvements, bug fixes and new features.
4
5- Intellij 2021.1.1 Platform Update
6- New Device Manager
7- ADB over Wi-Fi
8- Run Instrumented Tests in Android Studio using Gradle
9- Android Gradle Plugin Upgrade Assistant now updates API usage
10- Non-Transitive R classes on for new projects
11- Apple Silicon Support Update
12- Jank detection track in Profilers
13- Profileable app profiling support in Studio Profilers
14- Network Inspection and ability to capture Layout Inspector snapshots
15- Support for Compose semantics in the Layout Inspector
16- Interactive Preview
17- Animated Vector Drawables Preview
18- Updated Device picker for Design Tools
19
20Important After updating, you need to restart Android Studio to apply any memory settings you migrate from an earlier version of the IDE.
21Release Notes
22
However when I click on the Download button it opens a web page to re-download the whole program instead of updating it. It's a bit confusing because it's a minor update.
ANSWER
Answered 2022-Feb-10 at 11:09This issue was fixed by Google (10 February 2022).
You can now update Android Studio normally.
Thank you all for helping to bring this problem to Google's attention.
QUESTION
Is there way in ggplot2 to place text on a curved path?
Asked 2022-Feb-02 at 10:17Is there a way to put text along a density line, or for that matter, any path, in ggplot2? By that, I mean either once as a label, in this style of xkcd: 1835, 1950 (middle panel), 1392, or 2234 (middle panel). Alternatively, is there a way to have the line be repeating text, such as this xkcd #930 ? My apologies for all the xkcd, I'm not sure what these styles are called, and it's the only place I can think of that I've seen this before to differentiate areas in this way.
Note: I'm not talking about the hand-drawn xkcd style, nor putting flat labels at the top
I know I can place a straight/flat piece of text, such as via annotate
or geom_text
, but I'm curious about bending such text so it appears to be along the curve of the data.
I'm also curious if there is a name for this style of text-along-line?
Example ggplot2 graph using annotate(...)
:
Above example graph modified with curved text in Inkscape:
Edit: Here's the data for the first two trial runs in March and April, as requested:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13
ANSWER
Answered 2021-Nov-08 at 11:31Great question. I have often thought about this. I don't know of any packages that allow it natively, but it's not terribly difficult to do it yourself, since geom_text
accepts angle
as an aesthetic mapping.
Say we have the following plot:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24
And the following label that we want to run along it:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25
We can split the label into characters:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25label <- strsplit(label, "")[[1]]
26
Now comes the tricky part. We need to space the letters evenly along the path, which requires working out the x co-ordinates that achieve this. We need a couple of helper functions here:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25label <- strsplit(label, "")[[1]]
26next_x_along_sine <- function(x, d)
27{
28 y <- sin(x)
29 uniroot(f = \(b) b^2 + (sin(x + b) - y)^2 - d^2, c(0, 2*pi))$root + x
30}
31
32x_along_sine <- function(x1, d, n)
33{
34 while(length(x1) < n) x1 <- c(x1, next_x_along_sine(x1[length(x1)], d))
35 x1
36}
37
These allow us to create a little data frame of letters, co-ordinates and angles to plot our letters:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25label <- strsplit(label, "")[[1]]
26next_x_along_sine <- function(x, d)
27{
28 y <- sin(x)
29 uniroot(f = \(b) b^2 + (sin(x + b) - y)^2 - d^2, c(0, 2*pi))$root + x
30}
31
32x_along_sine <- function(x1, d, n)
33{
34 while(length(x1) < n) x1 <- c(x1, next_x_along_sine(x1[length(x1)], d))
35 x1
36}
37df2 <- as.data.frame(approx(df$x, df$y, x_along_sine(1, 1/13, length(label))))
38df2$label <- label
39df2$angle <- atan(cos(df2$x)) * 180/pi
40
And now we can plot with plain old geom_text
:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25label <- strsplit(label, "")[[1]]
26next_x_along_sine <- function(x, d)
27{
28 y <- sin(x)
29 uniroot(f = \(b) b^2 + (sin(x + b) - y)^2 - d^2, c(0, 2*pi))$root + x
30}
31
32x_along_sine <- function(x1, d, n)
33{
34 while(length(x1) < n) x1 <- c(x1, next_x_along_sine(x1[length(x1)], d))
35 x1
36}
37df2 <- as.data.frame(approx(df$x, df$y, x_along_sine(1, 1/13, length(label))))
38df2$label <- label
39df2$angle <- atan(cos(df2$x)) * 180/pi
40p + geom_text(aes(y = y + 0.1, label = label, angle = angle), data = df2,
41 vjust = 1, size = 4, fontface = "bold")
42
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25label <- strsplit(label, "")[[1]]
26next_x_along_sine <- function(x, d)
27{
28 y <- sin(x)
29 uniroot(f = \(b) b^2 + (sin(x + b) - y)^2 - d^2, c(0, 2*pi))$root + x
30}
31
32x_along_sine <- function(x1, d, n)
33{
34 while(length(x1) < n) x1 <- c(x1, next_x_along_sine(x1[length(x1)], d))
35 x1
36}
37df2 <- as.data.frame(approx(df$x, df$y, x_along_sine(1, 1/13, length(label))))
38df2$label <- label
39df2$angle <- atan(cos(df2$x)) * 180/pi
40p + geom_text(aes(y = y + 0.1, label = label, angle = angle), data = df2,
41 vjust = 1, size = 4, fontface = "bold")
42df$col <- cut(df$x, c(-1, 0.95, 2.24, 5), c("black", "white", "#000000"))
43
44ggplot(df, aes(x, y)) +
45 geom_line(aes(color = col, group = col)) +
46 geom_text(aes(label = label, angle = angle), data = df2,
47 size = 4, fontface = "bold") +
48 scale_color_identity() +
49 coord_equal() +
50 theme_bw()
51
or, with some theme tweaks:
Addendum
Realistically, I probably won't get round to writing a geom_textpath
package, but I thought it would be useful to show the sort of approach that might work for labelling density curves as per the OP's example. It requires the following suite of functions:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25label <- strsplit(label, "")[[1]]
26next_x_along_sine <- function(x, d)
27{
28 y <- sin(x)
29 uniroot(f = \(b) b^2 + (sin(x + b) - y)^2 - d^2, c(0, 2*pi))$root + x
30}
31
32x_along_sine <- function(x1, d, n)
33{
34 while(length(x1) < n) x1 <- c(x1, next_x_along_sine(x1[length(x1)], d))
35 x1
36}
37df2 <- as.data.frame(approx(df$x, df$y, x_along_sine(1, 1/13, length(label))))
38df2$label <- label
39df2$angle <- atan(cos(df2$x)) * 180/pi
40p + geom_text(aes(y = y + 0.1, label = label, angle = angle), data = df2,
41 vjust = 1, size = 4, fontface = "bold")
42df$col <- cut(df$x, c(-1, 0.95, 2.24, 5), c("black", "white", "#000000"))
43
44ggplot(df, aes(x, y)) +
45 geom_line(aes(color = col, group = col)) +
46 geom_text(aes(label = label, angle = angle), data = df2,
47 size = 4, fontface = "bold") +
48 scale_color_identity() +
49 coord_equal() +
50 theme_bw()
51#-----------------------------------------------------------------------
52# Converts a (delta y) / (delta x) gradient to the equivalent
53# angle a letter sitting on that line needs to be rotated by to
54# sit perpendicular to it. Includes a multiplier term so that we
55# can take account of the different scale of x and y variables
56# when plotting, as well as the device's aspect ratio.
57
58gradient_to_text_angle <- function(grad, mult = 1)
59{
60 angle <- atan(mult * grad) * 180 / pi
61}
62
63#-----------------------------------------------------------------------
64# From a given set of x and y co-ordinates, determine the gradient along
65# the path, and also the Euclidean distance along the path. It will also
66# calculate the multiplier needed to correct for differences in the x and
67# y scales as well as the current plotting device's aspect ratio
68
69get_path_data <- function(x, y)
70{
71 grad <- diff(y)/diff(x)
72 multiplier <- diff(range(x))/diff(range(y)) * dev.size()[2] / dev.size()[1]
73
74 new_x <- (head(x, -1) + tail(x, -1)) / 2
75 new_y <- (head(y, -1) + tail(y, -1)) / 2
76 path_length <- cumsum(sqrt(diff(x)^2 + diff(multiplier * y / 1.5)^2))
77 data.frame(x = new_x, y = new_y, gradient = grad,
78 angle = gradient_to_text_angle(grad, multiplier),
79 length = path_length)
80}
81
82#-----------------------------------------------------------------------
83# From a given path data frame as provided by get_path_data, as well
84# as the beginning and ending x co-ordinate, produces the appropriate
85# x, y values and angles for letters placed along the path.
86
87get_path_points <- function(path, x_start, x_end, letters)
88{
89 start_dist <- approx(x = path$x, y = path$length, xout = x_start)$y
90 end_dist <- approx(x = path$x, y = path$length, xout = x_end)$y
91 diff_dist <- end_dist - start_dist
92 letterwidths <- cumsum(strwidth(letters))
93 letterwidths <- letterwidths/sum(strwidth(letters))
94 dist_points <- c(start_dist, letterwidths * diff_dist + start_dist)
95 dist_points <- (head(dist_points, -1) + tail(dist_points, -1))/2
96 x <- approx(x = path$length, y = path$x, xout = dist_points)$y
97 y <- approx(x = path$length, y = path$y, xout = dist_points)$y
98 grad <- approx(x = path$length, y = path$gradient, xout = dist_points)$y
99 angle <- approx(x = path$length, y = path$angle, xout = dist_points)$y
100 data.frame(x = x, y = y, gradient = grad,
101 angle = angle, length = dist_points)
102}
103
104#-----------------------------------------------------------------------
105# This function combines the other functions to get the appropriate
106# x, y positions and angles for a given string on a given path.
107
108label_to_path <- function(label, path, x_start = head(path$x, 1),
109 x_end = tail(path$x, 1))
110{
111 letters <- unlist(strsplit(label, "")[1])
112 df <- get_path_points(path, x_start, x_end, letters)
113 df$letter <- letters
114 df
115}
116
117#-----------------------------------------------------------------------
118# This simple helper function gets the necessary density paths from
119# a given variable. It can be passed a grouping variable to get multiple
120# density paths
121
122get_densities <- function(var, groups)
123{
124 if(missing(groups)) values <- list(var)
125 else values <- split(var, groups)
126 lapply(values, function(x) {
127 d <- density(x)
128 data.frame(x = d$x, y = d$y)})
129}
130
131#-----------------------------------------------------------------------
132# This is the end-user function to get a data frame of letters spaced
133# out neatly and angled correctly along the density curve of the given
134# variable (with optional grouping)
135
136density_labels <- function(var, groups, proportion = 0.25)
137{
138 d <- get_densities(var, groups)
139 d <- lapply(d, function(x) get_path_data(x$x, x$y))
140 labels <- unique(groups)
141 x_starts <- lapply(d, function(x) x$x[round((length(x$x) * (1 - proportion))/2)])
142 x_ends <- lapply(d, function(x) x$x[round((length(x$x) * (1 + proportion))/2)])
143 do.call(rbind, lapply(seq_along(d), function(i) {
144 df <- label_to_path(labels[i], d[[i]], x_starts[[i]], x_ends[[i]])
145 df$group <- labels[i]
146 df}))
147}
148
With these functions defined, we can now do:
1df <- data.frame(
2 monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March',
3 'March', 'March', 'March', 'March', 'March', 'March', 'March',
4 'April', 'April', 'April', 'April', 'April', 'April', 'April',
5 'April', 'April', 'April', 'April', 'April', 'April', 'April'),
6 duration = c(36, 44, 45, 48, 50, 50, 51, 54, 55, 57, 60, 60, 60, 60, 30,
7 40, 44, 47, 47, 47, 53, 53, 54, 55, 56, 57, 69, 77)
8 )
9
10ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) +
11 geom_density() +
12 theme_minimal()`
13library(ggplot2)
14
15df <- data.frame(y = sin(seq(0, pi, length.out = 100)),
16 x = seq(0, pi, length.out = 100))
17
18p <- ggplot(df, aes(x, y)) +
19 geom_line() +
20 coord_equal() +
21 theme_bw()
22
23p
24label <- "PIRATES VS NINJAS"
25label <- strsplit(label, "")[[1]]
26next_x_along_sine <- function(x, d)
27{
28 y <- sin(x)
29 uniroot(f = \(b) b^2 + (sin(x + b) - y)^2 - d^2, c(0, 2*pi))$root + x
30}
31
32x_along_sine <- function(x1, d, n)
33{
34 while(length(x1) < n) x1 <- c(x1, next_x_along_sine(x1[length(x1)], d))
35 x1
36}
37df2 <- as.data.frame(approx(df$x, df$y, x_along_sine(1, 1/13, length(label))))
38df2$label <- label
39df2$angle <- atan(cos(df2$x)) * 180/pi
40p + geom_text(aes(y = y + 0.1, label = label, angle = angle), data = df2,
41 vjust = 1, size = 4, fontface = "bold")
42df$col <- cut(df$x, c(-1, 0.95, 2.24, 5), c("black", "white", "#000000"))
43
44ggplot(df, aes(x, y)) +
45 geom_line(aes(color = col, group = col)) +
46 geom_text(aes(label = label, angle = angle), data = df2,
47 size = 4, fontface = "bold") +
48 scale_color_identity() +
49 coord_equal() +
50 theme_bw()
51#-----------------------------------------------------------------------
52# Converts a (delta y) / (delta x) gradient to the equivalent
53# angle a letter sitting on that line needs to be rotated by to
54# sit perpendicular to it. Includes a multiplier term so that we
55# can take account of the different scale of x and y variables
56# when plotting, as well as the device's aspect ratio.
57
58gradient_to_text_angle <- function(grad, mult = 1)
59{
60 angle <- atan(mult * grad) * 180 / pi
61}
62
63#-----------------------------------------------------------------------
64# From a given set of x and y co-ordinates, determine the gradient along
65# the path, and also the Euclidean distance along the path. It will also
66# calculate the multiplier needed to correct for differences in the x and
67# y scales as well as the current plotting device's aspect ratio
68
69get_path_data <- function(x, y)
70{
71 grad <- diff(y)/diff(x)
72 multiplier <- diff(range(x))/diff(range(y)) * dev.size()[2] / dev.size()[1]
73
74 new_x <- (head(x, -1) + tail(x, -1)) / 2
75 new_y <- (head(y, -1) + tail(y, -1)) / 2
76 path_length <- cumsum(sqrt(diff(x)^2 + diff(multiplier * y / 1.5)^2))
77 data.frame(x = new_x, y = new_y, gradient = grad,
78 angle = gradient_to_text_angle(grad, multiplier),
79 length = path_length)
80}
81
82#-----------------------------------------------------------------------
83# From a given path data frame as provided by get_path_data, as well
84# as the beginning and ending x co-ordinate, produces the appropriate
85# x, y values and angles for letters placed along the path.
86
87get_path_points <- function(path, x_start, x_end, letters)
88{
89 start_dist <- approx(x = path$x, y = path$length, xout = x_start)$y
90 end_dist <- approx(x = path$x, y = path$length, xout = x_end)$y
91 diff_dist <- end_dist - start_dist
92 letterwidths <- cumsum(strwidth(letters))
93 letterwidths <- letterwidths/sum(strwidth(letters))
94 dist_points <- c(start_dist, letterwidths * diff_dist + start_dist)
95 dist_points <- (head(dist_points, -1) + tail(dist_points, -1))/2
96 x <- approx(x = path$length, y = path$x, xout = dist_points)$y
97 y <- approx(x = path$length, y = path$y, xout = dist_points)$y
98 grad <- approx(x = path$length, y = path$gradient, xout = dist_points)$y
99 angle <- approx(x = path$length, y = path$angle, xout = dist_points)$y
100 data.frame(x = x, y = y, gradient = grad,
101 angle = angle, length = dist_points)
102}
103
104#-----------------------------------------------------------------------
105# This function combines the other functions to get the appropriate
106# x, y positions and angles for a given string on a given path.
107
108label_to_path <- function(label, path, x_start = head(path$x, 1),
109 x_end = tail(path$x, 1))
110{
111 letters <- unlist(strsplit(label, "")[1])
112 df <- get_path_points(path, x_start, x_end, letters)
113 df$letter <- letters
114 df
115}
116
117#-----------------------------------------------------------------------
118# This simple helper function gets the necessary density paths from
119# a given variable. It can be passed a grouping variable to get multiple
120# density paths
121
122get_densities <- function(var, groups)
123{
124 if(missing(groups)) values <- list(var)
125 else values <- split(var, groups)
126 lapply(values, function(x) {
127 d <- density(x)
128 data.frame(x = d$x, y = d$y)})
129}
130
131#-----------------------------------------------------------------------
132# This is the end-user function to get a data frame of letters spaced
133# out neatly and angled correctly along the density curve of the given
134# variable (with optional grouping)
135
136density_labels <- function(var, groups, proportion = 0.25)
137{
138 d <- get_densities(var, groups)
139 d <- lapply(d, function(x) get_path_data(x$x, x$y))
140 labels <- unique(groups)
141 x_starts <- lapply(d, function(x) x$x[round((length(x$x) * (1 - proportion))/2)])
142 x_ends <- lapply(d, function(x) x$x[round((length(x$x) * (1 + proportion))/2)])
143 do.call(rbind, lapply(seq_along(d), function(i) {
144 df <- label_to_path(labels[i], d[[i]], x_starts[[i]], x_ends[[i]])
145 df$group <- labels[i]
146 df}))
147}
148set.seed(100)
149
150df <- data.frame(value = rpois(100, 3),
151 group = rep(paste("This is a very long label",
152 "that will nicely demonstrate the ability",
153 "of text to follow a density curve"), 100))
154
155ggplot(df, aes(value)) +
156 geom_density(fill = "forestgreen", color = NA, alpha = 0.2) +
157 geom_text(aes(x = x, y = y, label = letter, angle = angle),
158 data = density_labels(df$value, df$group, 0.8)) +
159 theme_bw()
160
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in R
Tutorials and Learning Resources are not available at this moment for R